Item click-through
SlimeDog opened this issue ยท 20 comments
Spigot 1.12.2 latest
ItemJoin 4.7
CommandSigns 1.5.5
changeWorld-item:
id: WATCH
data-value: 0
slot: 8
count: 1
name: '&bNavigate'
lore:
- 'Teleport elsewhere'
commands:
right-click:
- 'deluxemenus open navigation'
enchantment: FIRE_ASPECT:1
itemflags: cancel-events, death-drops, hide-attributes, hide-durability, inventory-modify, placement, self-drops, unbreakable
triggers: join, respawn, world-change
permission-node: 'deluxemenus.open'
enabled-worlds: list-of-worlds-which-includes-current-world
Due to permissions, DeluxeMenus cannot be opened in the current world. The slot 8 item (WATCH/clock) can be right-clicked through to trigger commands in a sign, despite cancel-events item flag.
In another world, where DeluxeMenus is enabled, the slot 8 item can again be right-clicked through to trigger commands in a sign, and DM menu is popped open.
In both cases, the right-click event should be canceled.
Ah wait so you are having an issue where if you hold the item in your hand and click on a sign that the item still executes the commands?
Let me be sure that I understand the meaning of
itemflags: cancel-events
My understanding is that with the flag set, the action configured for the IJ item -- in this case, open the DeluxeMenus menu -- would be executed. Any other actions initiated by the IJ item -- in this case, right-click on a sign -- would be canceled. Is that the intent, or is it something else?
cancel-events are for any action that isnt ItemJoin.
cancel-events are all events bukkit/Minecraft initiates.
Examples; opening a book, using a firework, eating food, tossing the hook to the fishing pole, etc.
That is if the item is each of those, so cancel-events wouldn't stop any firework from being launched, only if the item is a firework and it would only be that one specific item, so if ItemJoin gave two fireworks and one didn't have cancel-events then it would act as normal, as the itemflag is only specific to that certain item.
It cancels all events that the said item can trigger. So it can be a few dozen different things depending on the item.
I see. So how about right-click on a sign? My memory is that the right-click and the events behind it used to be canceled, but it and they are not, presently.
Right-click events on a sign would be canceled but not the command that is executed by ItemJoin as it is not an event.
Exactly. The item should raise the DeluxeMenus menu (or not, in the first case). But in neither case should the right-click pass through to the sign (as I understand it).
So just to be sure so I can test and fix this, you want the ItemJoin item to NOT execute the command if you click on an interactable such as a ServerSign that would execute its own command?
ItemJoin item = don't execute cmd.
Sign = execute command.
Srry its late xD
The command is executed as a result of the right-click, by DeluxeMenus. Surely that is an event; the issue is whether it can be trapped and canceled.
To double check, which event is supposed to trigger when you right-click the sign?
ItemJoin, or the Sign with the command bound to it?
Right-click on a sign triggers a CommandSigns sequence (for signs where that is configured; that is the issue here).
Right-click on the IJ item (WATCH=clock) triggers opening a DeluxeMenus menu.
changeWorld-item:
id: WATCH
data-value: 0
slot: 8
count: 1
name: '&bNavigate'
lore:
- 'Teleport elsewhere'
commands:
right-click:
- 'deluxemenus open navigation'
enchantment: FIRE_ASPECT:1
itemflags: cancel-events, death-drops, hide-attributes, hide-durability, inventory-modify, placement, self-drops, unbreakable
triggers: join, respawn, world-change
permission-node: 'deluxemenus.open'
The issue occurs when I right-click on the sign with the IJ item in hand. The commands behind the sign are executed and the DM menu opens.
Okay, so I understand what you are saying about the issue, what I don't understand;
Do you want me to have ItemJoin stop itself from executing the Deluxe Menu's command when clicking a sign so that CommandSigns sequence can execute?
Or
Do you want ItemJoin to cancel CommandSign from executing its sequence and allow the Deluxe Menu's command bound to the item to continue to execute?
I'm getting hung up on which operation is supposed to execute, ItemJoin (Being Deluxe Menu's) or CommandSign.
I understand the overall issue, just not which side.
There is also the possibility I am completely missing the issue due to my lack of intelligence xD.
I am working on setting up the exact same scenario in my test server right now.
IMHO: The IJ action should be triggered, and the click-through should not be triggered, if
itemflags: cancel-events
per wiki
cancel-events - Prevents player from opening a chest while this item is in hand or any open-able items. Useful for canceling the event of opening a book to set custom book items.
I appreciate that the implication is that cancel-events applies only to "open chest" (and maybe "open book"), but I think it should apply to all click-throughs. I guess that makes it a feature request.
The idea of cancel-events is it does apply to all events, I just advertise it more for like opening chests and things in that nature since some users don't understand it. Any PlayerInteract / PlayerClicked event. I'm not sure if it would be possible to cancel the click-through event as it ends up getting passed off to CommandSign.
Ill look to see what CommandSign listens on to see if I am missing an event, as well as you said that it worked on an older build of ItemJoin so I will test some old builds to see if I changed something.
Ill look into this and reply back in a short bit.
Found that the issue is that CommandSign ignores the cancelation when ItemJoin cancels the event. The events are indeed canceled but CommandSigns has the follow; @eventhandler(ignoreCancelled=true
Therefore it is canceled but CommandSigns gives the middle finger. I am currently looking to see if there is a way to mask this so CommandSigns will be tricked to think that the event was never triggered.
EDIT1: Nvm I am stupid.
EDIT2: Actually you were right, the events use to cancel, before MC 1.9 that is. Its a Mainhand / Offhand issue added in MC 1.9 causing the event to fire twice (Its specific to PlayerInteractEvent). I am looking to see why both aren't canceling.
EDIT3: Bingo, for some odd reason I had to set the EventHandler priority to LOWEST, then the CommandSigns would no longer send the command. I am going to create two instances of this for low and high so it will cover and cancel both spectrums.
BTW, sneak-click is passed through. I think this is a feature (ie., it should not be changed), but if that was not your intent...
ItemJoin v4.8 has been officially released containing this bug fix for official usage.
You can grab it here; https://www.spigotmc.org/resources/itemjoin.12661/download?version=223327
Please read the changelog as the documentation has not been updated yet;
https://www.spigotmc.org/wiki/recent-changes