out of bound null exception
mrfloris opened this issue ยท 10 comments
Versions
WorldEdit version:
> we version
[21:25:21 INFO]: WorldEdit version 7.2.0
[21:25:21 INFO]: https://github.com/EngineHub/WorldEdit/
[21:25:21 INFO]: ------------------ Platforms ------------------
* Bukkit-Official(7.2.0+a51fa43)
[21:25:21 INFO]: ---------------- Capabilities ----------------
GAME_HOOKS: Bukkit-Official
CONFIGURATION: Bukkit-Official
USER_COMMANDS: Bukkit-Official
PERMISSIONS: Bukkit-Official
WORLDEDIT_CUI: Bukkit-Official
WORLD_EDITING: Bukkit-Official
WorldGuard version:
> wg version
[21:25:36 INFO]: WorldGuard 7.0.4
[21:25:36 INFO]: http://www.enginehub.org
[21:25:36 INFO]: ----------- Platforms -----------
[21:25:36 INFO]: * Bukkit-Official (7.0.4+f7ff984)
>
Platform version:
> ver
[21:25:53 INFO]: This server is running Paper version git-Paper-356 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)
[21:25:53 INFO]: Checking version, please wait...
[21:25:53 INFO]: Previous version: git-Paper-354 (MC: 1.16.4)
[21:25:53 INFO]: You are 6 version(s) behind
>
Describe the bug
I noticed the exception in the console, I don't know what the player was doing, I've never had a wg error before actually.
[21:08:25 INFO]: Raikou_00 issued server command: /tpa EnderDip
[21:08:28 INFO]: EnderDip issued server command: /cmi tpaccept Raikou_00
[21:08:37 INFO]: general <Raikou_00> take bottle of enchanting
[21:08:47 INFO]: general <EnderDip> thanks
[21:09:00 INFO]: Raikou_00 issued server command: /home
[21:09:08 INFO]: general <Raikou_00> i need a home
[21:09:13 INFO]: general <EnderDip> u have one
[21:09:18 ERROR]: Could not pass event InventoryClickEvent to WorldGuard v7.0.4+f7ff984
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 36
at java.util.Arrays$ArrayList.get(Arrays.java:4351) ~[?:?]
at net.minecraft.server.v1_16_R3.NonNullList.get(SourceFile:46) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.PlayerInventory.getItem(PlayerInventory.java:541) ~[patched_1.16.4.jar:git-Paper-356]
at org.bukkit.craftbukkit.v1_16_R3.inventory.CraftInventory.getItem(CraftInventory.java:49) ~[patched_1.16.4.jar:git-Paper-356]
at com.sk89q.worldguard.bukkit.listener.BlacklistListener.checkEquipped(BlacklistListener.java:333) ~[?:?]
at com.sk89q.worldguard.bukkit.listener.BlacklistListener.onInventoryClick(BlacklistListener.java:292) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor458.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.16.4.jar:git-Paper-356]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.16.4.jar:git-Paper-356]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.16.4.jar:git-Paper-356]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:607) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:2540) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:32) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.PacketPlayInWindowClick.a(SourceFile:10) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:23) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1133) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1126) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeAll(IAsyncTaskHandler.java:95) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1262) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:997) ~[patched_1.16.4.jar:git-Paper-356]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:178) ~[patched_1.16.4.jar:git-Paper-356]
at java.lang.Thread.run(Thread.java:834) [?:?]
[21:09:20 ERROR]: Could not pass event InventoryClickEvent to WorldGuard v7.0.4+f7ff984
java.lang.ArrayIndexOutOfBoundsException: null
[21:09:20 INFO]: general <Raikou_00> a really small one
[21:09:26 INFO]: general <EnderDip> fair
[21:10:02 INFO]: general <mrfloris> *waves to Fr33_S0uL, hi btw
[21:10:06 INFO]: general <Raikou_00> there should be a trading mc
[21:10:09 INFO]: builders <Fr33_S0uL> *waves back* hi
[21:10:10 INFO]: general <Raikou_00> thing
To Reproduce
No idea, it just showed up, i thought it was worth reporting
Expected behavior
n/a, i expect it to not null, i guess?
Screenshots
rg info, i dont know where the players were, they were in the general world, but could have been in a region, as far as i know they were building in a new area and dont have region protection from us yet. i have no xyz
Additional context
on a private discord it was suggested this could be caused by wg going through the inventory checking for blacklisted items?
Seems like spigot is reporting invalid slot numbers for inventory events.
JavaDocs say
int | getHotbarButton() | If the ClickType is NUMBER_KEY, this method will return the index of the pressed key (0-8).
but it returned -1 for whatever reason.
Maybe I'm missing something with how spigot handles inventory slots or something? Code on our side looks pretty straightforward.
case HOTBAR_SWAP:
return clickedInventory == null ? null : clickedInventory.getItem(event.getHotbarButton());
getHotbarButton()
only returns the hotbar button if InventoryAction == NUMBER_KEY
, which HOTBAR_SWAP
is not.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryClickEvent.html#getHotbarButton()
Not really sure what the alternative here is, I certainly tested this swapping armor into my hotbar and it worked fine.
I ran into something similar to this before, the offhand swap key (f) by will pass a -1 in here
The player in question seems to like shields and elytra - they were building. It would perhaps make sense if they were swapping their inventory around with keys (if this info helps)
Ok, so clearly the javadocs on getHotbarButton are wrong, since they definitely are valid for actual hotbar swaps, but then offhand swaps somehow also count as hotbar swaps but don't return in range. I guess if it's -1 we can only assume it's an offhand swap and have to manually check the offhand slot ourselves?
I can't reproduce this, the offhand slot is apparently a quickbar slot not an armor slot, so the entire switch statement doesn't even fire.
(This seems to also mean that the blacklist on-equip event won't work for shields, but that's a separate issue lol).
edit: nvm reprod, nothing to do with shields.
edit2: also not really worth trying to do on-equip for shields since you can use them in your mainhand too, not just offhand. would need to block on-acquire if that's the intended purpose i guess.