Hello
so I am trying to do something with the InventoryClickEvent for an anvil which I open through a command. I am facing the issue that I am getting an IndexOutOfBound***ception? Code is below I hope someone could help me. (Spigot 1.88 / 1.89)
Command to open the anvil inventory:
Hey,
ich versuche gerade das InventoryClickEvent auf einen Amboss anzuwenden den ich in dem Sinne selbst über einen Befehl erstelle und anzeige. Das Problem ist jedoch das ich eine IndexOutOfBound***ception erhalte. Die Spigot Version ist die 1.88 / 1.89
so I am trying to do something with the InventoryClickEvent for an anvil which I open through a command. I am facing the issue that I am getting an IndexOutOfBound***ception? Code is below I hope someone could help me. (Spigot 1.88 / 1.89)
Command to open the anvil inventory:
Hey,
ich versuche gerade das InventoryClickEvent auf einen Amboss anzuwenden den ich in dem Sinne selbst über einen Befehl erstelle und anzeige. Das Problem ist jedoch das ich eine IndexOutOfBound***ception erhalte. Die Spigot Version ist die 1.88 / 1.89
Befehl um den Amboss anzuzeigen:
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player) {
Player p = (Player)sender;
if(p.hasPermission(commandPermission)) {
Inventory anvilView = Bukkit.createInventory(p, InventoryType.ANVIL);
p.openInventory(anvilView);
}
}
return false;
}
InventoryClickEvent:
@EventHandler
public void onClick(InventoryClickEvent e) {
if(e.getInventory().getType() == InventoryType.ANVIL) {
if(e.getCurrentItem().getAmount() != 1) {
e.setCancelled(true);
}
}
}
Exception:
[19:45:43 FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.IndexOutOfBound***ception: Index: 15, Size: 0
at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_231]
at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_231]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:45) [spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:715) [spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot188.jar:git-Spigot-db6de12-18fbb24]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_231]
Caused by: java.lang.IndexOutOfBound***ception: Index: 15, Size: 0
at java.util.ArrayList.rangeCheck(Unknown Source) ~[?:1.8.0_231]
at java.util.ArrayList.get(Unknown Source) ~[?:1.8.0_231]
at net.minecraft.server.v1_8_R3.Container.getSlot(Container.java:109) ~[spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1463) ~[spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:31) ~[spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:9) ~[spigot188.jar:git-Spigot-db6de12-18fbb24]
at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) ~[spigot188.jar:git-Spigot-db6de12-18fbb24]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_231]
at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_231]
at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[spigot188.jar:git-Spigot-db6de12-18fbb24]
... 5 more