hpfxd / PandaSpigot

Fork of Paper for 1.8.8 focused on improved performance and stability.
GNU General Public License v3.0
224 stars 64 forks source link

[FIX ERROR EXECUTING TASK] Error in console when dropping an item from an inventory with an index greater than 45. #173

Open SniperTVmc opened 6 months ago

SniperTVmc commented 6 months ago

Hi, I've developped a Java Plugin, in which allow me to manage custom created inventories.

Then, in a custom created chest inventory (from 1 to 6 rows), when I try to "drop" (just the action, the drop keystroke) an item from row 3 to 6, I receive an error in the console. Theresn't really a problem which impact the players's gameplay, but if we can avoid to receive or spam the console of this errors, that can be great. :)

Thank you and good work for this PaperSpigot fort! :D

image

[15:22:53 FATAL]: Error executing task
java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index 49 out of bounds for length 45
    at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:?]
    at java.util.concurrent.FutureTask.get(FutureTask.java:191) ~[?:?]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:12) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:881) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:412) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:815) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:648) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.MinecraftServer.lambda$spin$0(MinecraftServer.java:133) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at java.lang.Thread.run(Thread.java:1589) [?:?]
Caused by: java.lang.IndexOutOfBoundsException: Index 49 out of bounds for length 45
    at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100) ~[?:?]
    at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) ~[?:?]
    at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) ~[?:?]
    at java.util.Objects.checkIndex(Objects.java:385) ~[?:?]
    at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
    at net.minecraft.server.v1_8_R3.Container.getSlot(Container.java:109) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1737) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:17) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(PacketPlayInWindowClick.java:5) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(PlayerConnectionUtils.java:9) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577) ~[?:?]
    at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
    at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:11) ~[patched_1.8.8.jar:git-PandaSpigot-115]
    ... 6 more
uRyanxD commented 6 months ago

Hi @SniperTVmc, could you send a video showing the problem? I was unable to reproduce the issue.

SniperTVmc commented 6 months ago

Here the two moments when the error occurs are when I try to throw the item from the GUI. Normaly this item is used to close the GUI, I don't know if this has anything to do with it?

[

https://github.com/hpfxd/PandaSpigot/assets/53542570/6dc11c5b-9eba-4544-889f-20e2e8150a16

](url)

And here's the part of my code that might influence the problem:

@EventHandler
    public void onInventoryClick(InventoryClickEvent event) {

        ItemStack clickedItem = event.getCurrentItem();
        Player player = (Player) event.getWhoClicked();

        if ((player.getOpenInventory().getTitle().equals("§8§l» §8Menu Principal"))) {

            if (clickedItem != null && clickedItem.getType() != Material.AIR) {
                String clickedItemName = clickedItem.getItemMeta().getDisplayName();

                if (clickedItemName.equals("§8§l» §6§lHunters's Strike")) {
                    sendPlayerToServer.sendPlayerToServer(player, "hsSolo01");
                    return;
                }

                if (clickedItemName.equals("§8§l» §c§lFermer le Menu")) {
                    player.closeInventory();
                    player.playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.0f, 1.0f);
                    return;
                }
            }
        }
    }