1.17.x Opening custom inventory causes server to crash in 1.17

Discussion in 'Spigot Plugin Development' started by SkrenZz, Jun 11, 2021.

  1. Hello there,

    I have made a plugin that opens custom, interactable inventories (shops). Everything was working properly until I upgraded my server version to Spigot 1.17 earlier today. Now, every time I try to use the plugin and open the custom inventory, it causes the server to crash.

    I've read the console error logs, but could not find anything helpful:
    Code (Text):
    11.06 15:48:09 [Server] Server thread/ERROR Could not pass event PlayerInteractEvent to Economy v1.3.9
    11.06 15:48:09 [Server] INFO org.bukkit.event.EventException: null
    11.06 15:48:09 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:499) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:466) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at org.bukkit.craftbukkit.v1_17_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:462) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1591) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.network.protocol.game.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:28) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.network.protocol.game.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.util.thread.IAsyncTaskHandler.executeTask(SourceFile:151) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.util.thread.IAsyncTaskHandler.executeNext(SourceFile:125) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1124) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.MinecraftServer.executeNext(MinecraftServer.java:1117) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.util.thread.IAsyncTaskHandler.awaitTasks(SourceFile:134) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.MinecraftServer.sleepForTick(MinecraftServer.java:1101) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1030) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:307) ~[spigot_1.17.jar:3100-Spigot-c9cea60-5182f92]
    11.06 15:48:09 [Server] INFO at java.lang.Thread.run(Thread.java:831) [?:?]
    11.06 15:48:09 [Server] INFO Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
    11.06 15:48:09 [Server] INFO at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
    11.06 15:48:09 [Server] INFO at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
    11.06 15:48:09 [Server] INFO at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
    11.06 15:48:09 [Server] INFO at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
    11.06 15:48:09 [Server] INFO at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
     
    Here is the code that displays the shop:
    Code (Text):
    public void DisplayShop(Player player)
        {
            Inventory shopGui = Bukkit.createInventory(player, this.guiSize, this.title);
            for (ShopItem shopItem : this.items)
            {
                shopGui.setItem(shopItem.GetSlotIndex(), shopItem.GetShopItemStack(player));
            }
           
            player.openInventory(shopGui);
            ShopListener.playerOpenShop.put(player, this);
        }
    I would very much appreciate every attempt to help me,
    Thanks a lot in advance and have a wonderful day!
     
  2. Thanks for your comment, could you please explain what you mean by being on 3111?
     
  3. Build version.
     
  4. I am actually not sure... If I am not mistaken, these console logs indicate that the build version is 3100:
    Code (Text):
    11.06 17:24:35 [Server] Server thread/INFO Starting minecraft server version 1.17
    11.06 17:24:35 [Server] Server thread/INFO Loading properties
    11.06 17:24:35 [Server] Server thread/INFO This server is running CraftBukkit version 3100-Spigot-c9cea60-5182f92 (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
     
    I actually have no idea if that's how I am supposed to check that, and how to change the build version...
     
  5. You must rebuild spigot 1.17
     
  6. Off-topic: functions in Java usually get named starting with the lowercase letter. Aside that, I don't see anything wrong with the code :(
     
  7. 3100 = 11 builds behind at the time, which can include fixes that relate to you
     
  8. I've been trying to do that using the build tools but I'm dealing with many technical difficulties... Is there any other way I could get the up-to-date build version of Spigot 1.17?

    Many thanks for your help!
     
  9. no. Only use BuildTools.
     
  10. You have Ubuntu or macOS machine where you can run shell scripts from?
    If so, you can use this: <https://github.com/mrfdev/1MB/blob/master/Resources/Spigot/1MB-BuildTools.sh>
    chmod a+x 1MB-BuildTools.sh
    just once, and then to run it, put it in a new empty dir and type: ./1MB-BuildTools.sh

    it will try to find what's required to run adn report back when it can't. and gets buildtools, compiles 1.17 and gives you a spigot jar and tells you where it put it.
     
  11. I have finally managed to build the updated version of spigot. Hopefully it will go smoother next time I do it...
    Thank you all very very much for your help!!!
     
    #12 SkrenZz, Jun 11, 2021
    Last edited: Jun 11, 2021
  12. I'm having this same issue :(
    How did you manage to build the updated version of spigot??
     
  13. BuildTools.jar <- is how you get --rev 1.17 builds

    and the frontpage has the details. read it