Solved Open Inventory null pointer?

Discussion in 'Spigot Plugin Development' started by wireser, Jun 11, 2021 at 10:33 AM.

  1. For debug purpouses I reduced my code to 4 lines:
    Code (Java):
    public static void open(Player player) {
            Inventory inv = Bukkit.createInventory(player, 9, "Main menu");
            player.openInventory(inv);
    }
    When the method is called the server crashes with this error:
    Protocol error. Ignoring packet - Socket closed
    Exception stopping the server
    java.lang.IndexOutOfBoundsExceptionIndex 9 out of bounds for length 0

    Does anybody know what causes this?
    Its worked perfectly before I updated to 1.17.



    Code (Text):
    [11.06 11:27:50] [Server] [Server thread/ERROR]: null
    [11.06 11:27:50] [Server] org.bukkit.command.CommandExceptionUnhandled exception executing command 'menu' in plugin TheMeetCraftPlugin v5.7.0
    [11.06 11:27:50] [Server]     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at org.bukkit.craftbukkit.v1_17_R1.CraftServer.dispatchCommand(CraftServer.java:764) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.network.PlayerConnection.handleCommand(PlayerConnection.java:1943) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1782) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1763) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1124) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1117) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(SourceFile:134) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1101) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1030) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:307) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at java.lang.Thread.run(Thread.java:831) [?:?]
    [11.06 11:27:50] [Server] Caused byjava.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
    [11.06 11:27:50] [Server]     at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
    [11.06 11:27:50] [Server]     at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
    [11.06 11:27:50] [Server]     at net.minecraft.core.NonNullList.get(SourceFile:46) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.b(Container.java:272) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.d(Container.java:228) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.addSlotListener(Container.java:161) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.EntityPlayer.initMenu(EntityPlayer.java:545) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at org.bukkit.craftbukkit.v1_17_R1.entity.CraftHumanEntity.openCustomInventory(CraftHumanEntity.java:325) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at org.bukkit.craftbukkit.v1_17_R1.entity.CraftHumanEntity.openInventory(CraftHumanEntity.java:303) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at menu.Base.open(Base.java:28) ~[?:?]
    [11.06 11:27:50] [Server]     at main.Main.onCommand(Main.java:646) ~[?:?]
    [11.06 11:27:50] [Server]     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     ... more
    [11.06 11:27:50] [Server] [Server thread/ERROR]: Encountered an unexpected exception
    [11.06 11:27:50] [Server] net.minecraft.ReportedExceptionTicking entity
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1309) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:436) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1199) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1026) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:307) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at java.lang.Thread.run(Thread.java:831) [?:?]
    [11.06 11:27:50] [Server] Caused byjava.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
    [11.06 11:27:50] [Server]     at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
    [11.06 11:27:50] [Server]     at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
    [11.06 11:27:50] [Server]     at net.minecraft.core.NonNullList.get(SourceFile:46) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.b(Container.java:272) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.d(Container.java:228) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.EntityPlayer.tick(EntityPlayer.java:588) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.WorldServer.entityJoinedWorld(WorldServer.java:815) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.level.World.a(World.java:692) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.WorldServer.lambda$11(WorldServer.java:527) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.level.entity.EntityTickList.a(SourceFile:54) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.WorldServer.doTick(WorldServer.java:508) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1296) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     ... more
    [11.06 11:27:50] [Server] [Server thread/ERROR]:     Cause of unexpected exception was
    [11.06 11:27:50] [Server] java.lang.IndexOutOfBoundsExceptionIndex 0 out of bounds for length 0
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
    [11.06 11:27:50] [Server]     at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
    [11.06 11:27:50] [Server]     at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
    [11.06 11:27:50] [Server]     at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
    [11.06 11:27:50] [Server]     at net.minecraft.core.NonNullList.get(SourceFile:46) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.b(Container.java:272) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.inventory.Container.d(Container.java:228) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.EntityPlayer.tick(EntityPlayer.java:588) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.WorldServer.entityJoinedWorld(WorldServer.java:815) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.level.World.a(World.java:692) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.WorldServer.lambda$11(WorldServer.java:527) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.world.level.entity.EntityTickList.a(SourceFile:54) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.level.WorldServer.doTick(WorldServer.java:508) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1296) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:436) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1199) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1026) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:307) ~[spigot-1.17.jar:3104-Spigot-a09c0bb-d747f8e]
    [11.06 11:27:50] [Server]     at java.lang.Thread.run(Thread.java:831) [?:?]
    [11.06 11:27:50] [Server] [Server thread/ERROR]: This crash report has been saved to: /./crash-reports/crash-2021-06-11_10.27.50-server.txt
     
  2. I'm having the same exact issue with one of my plugins, trying to update it to 1.17. Still haven't figured it out though, but if you find a solution, please post it here. I'll do the same if I solve it first.
     
  3. Found the solution. It was a spigot bug (https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-6506?filter=addedrecently). Just build a new spigot jar. It worked for me (the bug tracker says it was fixed two hours ago so this is pretty new.
     
    • Winner Winner x 1
    • Useful Useful x 1