Hotkey cheat in icon menus
armbruer opened this issue ยท 3 comments
Steps to reproduce:
- Create an iconmenu in any of your plugins.
(I'm using this icon menu resource: http://forums.bukkit.org/threads/icon-menu.108342/) - Open it whenever a player right clicks item X.
- Hover with your mouse over any icon in the icon menu.
- Look into your inventory in which slot is the item X. Then press this hotkey (slot of Icon X)
-> You cheated the item you hovered over.
I think this is because you set in your inventoryclickevent ignorecancelled true. (But I didn't have a closer look at this so far)
Thanks for reading. Hope you can fix this.
darkness19
IgnoreCancelled does the opposite of what you think it does. It's equivalent to checking for isCancelled() and returning: https://forums.bukkit.org/threads/ignore-cancelled-events.61155/
I will look into the IconMenu though.
Actually, this looks like a pretty major flaw in the IconMenu priority you are using.
Replace
@EventHandler(priority=EventPriority.MONITOR)
void onInventoryClick(InventoryClickEvent event) {
with
@EventHandler(priority=EventPriority.LOWEST)
void onInventoryClick(InventoryClickEvent event) {
Currently with MONITOR, the IconMenu is waiting for all other plugins to handle the inventory first. Since you want to handle IconMenu for this specific inventory every time, you should force IconMenu to go first by giving it the lowest priority.
Also, with the priority set to MONITOR, cancelling the event will only cancel other MONITOR events (assuming they go after), changing it to LOWEST will cancel pretty much all other events (unless they also happen to be LOWEST and go first)