Item click-through
SlimeDog opened this issue ยท 23 comments
Spigot 1.14.4 latest or Spigot 1.13.2 final
ItemJoin 5.0.4-b285
DeluxeMenus 1.12.0
Skript 2.4-beta5
Right-click on CLOCK item opens the DeluxeMenus menu, but also acts on the iron_door at which the click is aimed, which triggers a Skript to toggle the iron_door. This occurs even though itemflags includes cancel-events. The issue does not occur if the right-click would trigger a vanilla toggle event (for example, if the target were a wooden door).
Similar to, or perhaps reappearance of, #163.
ItemJoin items.yml (relevant portion):
changeWorld-tool:
id: CLOCK
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: world, world_lobby, world_blackdog
and config.yml (sans comments):
config-Version: 7
Language: 'English'
General:
CheckforUpdates: false
Metrics-Logging: false
Log-Coloration: false
Log-Commands: true
Debugging: false
Settings:
HeldItem-Slot: 0
DataTags: true
Permissions:
Obtain-Items: false
Obtain-Items-OP: false
Commands-Get: false
Commands-OP: false
Movement-Bypass: false
Clear-Items:
Type: ITEMJOIN
Delay-Tick: 2
Join: DISABLED
World-Switch: DISABLED
Options: PROTECT
Bypass: DISABLED
Active-Commands:
commands:
- 'itemjoin get <item> <player>'
- 'first-join: say This is a command only executed once per world, per player.'
triggers: JOIN
enabled-worlds: DISABLED
Prevent:
Pickups: DISABLED
itemMovement: DISABLED
Bypass: DISABLED
softDepend:
Multiverse-Core: true
Multiverse-Inventories: true
PlaceholderAPI: true
Vault: true
WorldGuard: true
AuthMe: false
BetterNick: false
HeadDatabase: false
MyWorlds: false
PerWorldInventory: false
PerWorldPlugins: false
TokenEnchant: false
xInventories: false
and the Skript:
on rightclick on iron door:
toggle the block
cancel the event
Is this specific to the latest dev build (occurring after you updated) or do you think this has been an existing issue prior to build #285?
EDIT: Hmmm... This kinda seems like it must have also occurred before the 285 update, since the cancel-events itemflag can only cancel vanilla minecraft events and rarely is able to interfere with other plugins. I'll have to do a lot of testing with this lol.
I agree. The event in question is not vanilla. However, non-IJ items do not have this issue.
UPDATE: Issue existed in previous versions of ItemJoin.
Sorry I was just about to complete this issue today/tomorrow. I have been working on it and I have replicated the issue. I am still working on a method to resolve this though.
I have been spending a majority of the time finishing the item creator gui which you will see pushed to the snapshot branch later tomorrow.
Expect to see a reply on this issue tomorrow or the day after.
Starting to think that this might not be possible... the event is successfully canceled as first priority but I think Skript has it set to ignore canceled events. I have been skimming through the GitHub repo for Skript but I am still unable to find the exact listener being used to see if it's true or not.
Did a little trick to see if I was right and it turns out I was. The attached image shows ItemJoin cancelling the event before the Skript message is executed so it is, in fact, ignoring cancellations.
I was just able to attach a debug message to their event using the Skript you gave me and attaching a message to the end.
on rightclick on iron door:
toggle the block
cancel the event
send "Skript Event Failed To Cancel" to CONSOLE
The skript toggles an iron door for players with appropriate permissions.
The non-IJ items are just regular items in the inventory, so they are in the main hand (or not -- the skript works with an empty hand). If I right-click the target door with a non-IJ item, the skript successfully toggles the door, then cancels the (inherent block placement) event. All good.
The issue is with the IJ item, a clock which when right-clicked opens a DM menu. The analysis:
- Right-click the IJ item while targeting an iron door controlled by the Skript above: the door is toggled, and the DM menu is opened.
- Right-click the IJ item while targeting a wooden door not controlled by the Skript above: the door is not toggled (the event is correctly canceled by Skript), and the DM menu is opened.
- Right-click the IJ item while targeting a block on which a clock can be placed, such as an item_frame: The clock is not placed (the event is canceled by IJ, as configured), and the DM menu is not opened.
- Right-Click the IJ item while targeting a block on which a clock cannot be placed: The DM menu is opened, as expected.
Ohhhhhh so I am getting this backward then, you want to cancel the menu being opened not the door haha.
No! I want the door not to be toggled. I want the DM menu to open. From what you say, this is not possible.
Ah, I see sorry I got confused by the non-IJ item's events you were talking about. Yeah, those block placement events are canceled by Skript which is why they aren't placed.
The doors that are not controlled by Skript are not opened because they are respecting the cancelation boolean placed on the event. Skript seems to be bypassing it and opening the door regardless. I have opened an issue on their GitHub to get some insight into this but it sounds like something they would have to change on their end so they either respect the cancelation boolean OR respect the cancelation ONLY when it is canceled by ItemJoin specifically.
As for the itemframe commands should technically be executing for that (opening the menu) however, since it is an entity it doesn't. I added a specific listener which will push to the snapshot soon that resolves this problem. This also happened for MOBS as well weirdly enough.
okay SO! It turns out the issue was a mix of a couple things.
1.) Skript DOES ignore canceled events, this is intended.
2.) Every Skript that you want ItemJoin to effectively be able to cancel-events you will need to add the line if event is not cancelled:
to your Skripts as shown in the example below. http://skriptlang.github.io/Skript/conditions.html#CondCancelled
3.) You will also have to download the latest snapshot of ItemJoin in order for this to work. Apparently Skript listens to the offhand interact event instead of the mainhand which both are always triggered when clicking since MC 1.9.. So ItemJoin simply cancels both now; http://ci.craftationgaming.com/job/ItemJoin/287/
on rightclick on iron door:
if event is not cancelled:
toggle the block
cancel the event
Interesting. The skript is very simple
on rightclick on iron door:
player has permission "blackdog.sesame"
toggle the block
cancel the event
It works fine for non-IJ items. I can actually see the event performed -- such as placing a torch -- and then canceled, so the torch flashes into place and then is quickly removed. But with the IJ item, the event is not canceled.
Are you meaning items that are created (managed) via Skript?
I have managed to cancel the event by simply unregistering the listener that Skript is using for the PlayerInteractEvent but I haven't found a way or re-registering it. Which is what lead me to the idea that Skript might simply be ignoring canceled events which is a simple parameter for the listener which then makes it impossible to cancel.
I still have yet to find the exact location in their code which handles this event so I think I am going to drop an issue post on their GitHub and see if I can get a response.
Done :)
http://ci.craftationgaming.com/job/ItemJoin/292/
-- I have no idea how this will affect the plugin checking for updates, I haven't tested it yet lol.
Build number exists on the end of the jar file as well as the plugin.yml so typing /itemjoin (will display the build number)
Nice. My automagical update-checker displays:
plugin source jar version running version latest release date status
-------- ------- ----------- --------------- -------------- ---------- --------
ItemJoin Jenkins 5.0.4-b289 5.0.4-b289 * 5.0.4-b290 2019-09-13 update
which is perfect.
however...
Spigot 1.14.4
ItemJoin 5.0.4-SNAPSHOT-b292
[22:06:50] [Server thread/INFO]: [ItemJoin] Enabling ItemJoin v5.0.4-SNAPSHOT-b292
[22:06:50] [Server thread/INFO]: [ItemJoin] Fetched [{ Multiverse-Core, Multiverse-Inventories, WorldGuard, PlaceholderAPI, Vault }]^[[m
[22:06:50] [Server thread/ERROR]: Error occurred while enabling ItemJoin v5.0.4-SNAPSHOT-b292 (Is it up to date?)
java.lang.NumberFormatException: For input string: "504-292"
at jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054) ~[?:?]
at jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110) ~[?:?]
at java.lang.Double.parseDouble(Double.java:543) ~[?:?]
at me.RockinChaos.itemjoin.handlers.UpdateHandler.<init>(UpdateHandler.java:29) ~[?:?]
at me.RockinChaos.itemjoin.handlers.ConfigHandler.generateData(ConfigHandler.java:47) ~[?:?]
at me.RockinChaos.itemjoin.ItemJoin.onEnable(ItemJoin.java:14) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:461) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:375) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:449) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at net.minecraft.server.v1_14_R1.DedicatedServer.init(DedicatedServer.java:266) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:775) [spigot-1.14.4.jar-2019-09-13-0714:git-Spigot-94af569-6ddeb98]
at java.lang.Thread.run(Thread.java:834) [?:?]
Sorry about that, had a feeling that would happen.
Did some tweaking and (I did test it) and it seems to be working, as well as it seems happy with the existing release builds on spigotmc so this seems like a fantastic edition.
Probably would have never done it unless you requested it so I am happy you did.
http://ci.craftationgaming.com/job/ItemJoin/293/
Yes! This works as expected for all tested variations (see bullet points in "Analysis" above) with build 289.
Feature request: It would be nice if the version string in plugins.yml included the build number. For example, instead of:
- 5.0.4-SNAPSHOT
it would be one of:
- 5.0.4-SNAPSHOT-b289
- 5.0.4-b289
This is something I actually intensely worked on when I first started the Jenkins repo site. However (At the time) it wasn't really feasible and was quite complex as Jenkins wasn't really friendly with modifying yaml files during compilation.
However, I will take another look at it and see what has changed. A little birdy told me it has gotten a lot easier now, and honestly would be VERY useful for me to keep track of things.
This bug has been officially fixed in the release of ItemJoin v5.0.4.
You can grab it here; https://www.spigotmc.org/resources/itemjoin.12661/download?version=295178
Please read the changelog as the documentation has not been updated yet;
https://github.com/RockinChaos/ItemJoin/wiki/Recent-Changes