MinusKube / SmartInvs

Advanced Inventory API for your Minecraft Bukkit plugins.
https://minuskube.gitbook.io/smartinvs/
Apache License 2.0
263 stars 65 forks source link

PlayerInteractEvent getting called when clicking item #147

Closed gkhaavik closed 3 years ago

gkhaavik commented 4 years ago

PlayerInteractEvent is getting called when clicking on a clickable item that is not empty, it is causing a bug since I am trying to open a menu when player clicks with a specific item.

https://giphy.com/gifs/KbvhGts33HSVNpMQxq

MinusKube commented 4 years ago

That's weird, what SmartInvs and Spigot versions are you using?

gkhaavik commented 4 years ago

Using latest smartInv 1.2.7 and latest paper spigot

gkhaavik commented 4 years ago

I should probably mention I have 2 plugins on my server that uses SmartInvs seperately

gkhaavik commented 4 years ago

I am still having this issue

gkhaavik commented 4 years ago

Please fix this :)

MinusKube commented 4 years ago

Not able to reproduce the issue, can you provide some short code which shows the issue please?

gkhaavik commented 4 years ago

First of all I have 2 plugins using the SmartInvs library, which I have noticed to cause some trouble when using plugman to reload one of those plugins.

How I create Menus https://pastebin.com/DP1cfxLr My MenuProvider https://pastebin.com/0cVUyiib If the player right-clicks or left-clicks with a specific item, it should open a menu. This is done using PlayerInteractEvent. It works great the first time the player does it, but when the menu is open and the player clicks on the interactableitems, while having the specific item in their hand. It does the interactableitem action first and afterwards just reopens the menu, so it looks like nothing happens.

MinusKube commented 4 years ago

Are the 2 plugins providing their own version of SmartInvs inside the jars, or are they directly using the SmartInvs plugin from the plugins folder as a dependency?

gkhaavik commented 4 years ago

They providing their own with maven repo

gkhaavik commented 4 years ago

They are*

MinusKube commented 4 years ago

Then that may be the problem, if two different InventoryManager are initialized, maybe it causes some conflicts

gkhaavik commented 4 years ago

Yeah I know, that why I mentioned it but what should I do? I dont want to have people require the plugin as a dependecy.

MinusKube commented 4 years ago

You can put the API in one of the plugin, and making the second plugin depend on the first one

gkhaavik commented 4 years ago

It is two completly different plugins

MinusKube commented 4 years ago

Can you check with only one of those 2 plugins to see if the problem is really caused by some kind of "conflict"?

gkhaavik commented 4 years ago

I have checked, when I only have one of the plugins on, plugman reload works great, but when both, thats when I get the error.

MinusKube commented 4 years ago

Maybe if you relocate the SmartInvs package inside one of your plugin, so they don't get considered as the same plugin?

If that doesn't work, then I don't know any other solution than using SmartInvs in a standalone plugin, but if you don't want users to need to manually download it, maybe you can provide it inside a zip file besides your plugin, or make it automatically download SmartInvs from the Github Releases page

gkhaavik commented 4 years ago

I noticed that at some point in this thread, I changed subject, the issue was that PlayerInteractEvent was being called clicking on interactable items inside a SmartInventory menu.

MinusKube commented 4 years ago

I don't understand what's causing the PlayerInteractEvent call, since it's called nowhere in our code

gkhaavik commented 4 years ago

Do you know what I mean?

MinusKube commented 4 years ago

Yeah I think I understand the problem, but I don't know what could be the cause. Is this problem still happening when only one of the two plugins is enabled?