MinusKube / SmartInvs

Advanced Inventory API for your Minecraft Bukkit plugins.
https://minuskube.gitbook.io/smartinvs/
Apache License 2.0
263 stars 65 forks source link

add try/finally block #156

Closed wysohn closed 4 years ago

wysohn commented 4 years ago

This prevent the exception caused by the registered listener causing the plugin to spam the console.

Spam example:

[17:09:24] [Server thread/WARN]: [SmartInvs] Task #15804 for SmartInvs v1.3.0 generated an exception
java.lang.ArrayIndexOutOfBoundsException: 7
    at java.util.Arrays$ArrayList.set(Arrays.java:3846) ~[?:1.8.0_265]
    at net.minecraft.server.v1_16_R1.NonNullList.set(SourceFile:53) ~[patched_1.16.1.jar:git-Paper-135]
    at net.minecraft.server.v1_16_R1.InventoryCrafting.setItem(InventoryCrafting.java:134) ~[patched_1.16.1.jar:git-Paper-135]
    at org.bukkit.craftbukkit.v1_16_R1.inventory.CraftInventoryCrafting.setItem(CraftInventoryCrafting.java:80) ~[patched_1.16.1.jar:git-Paper-135]
    at fr.minuskube.inv.content.InventoryContents$Impl.update(InventoryContents.java:929) ~[?:?]
    at fr.minuskube.inv.content.InventoryContents$Impl.set(InventoryContents.java:696) ~[?:?]
    at io.github.wysohn.tradegui.manager.gui.GUIPairNode.update(GUIPairNode.java:117) ~[?:?]
    at fr.minuskube.inv.InventoryManager$PlayerInvTask.run(InventoryManager.java:299) ~[?:?]
    at org.bukkit.craftbukkit.v1_16_R1.scheduler.CraftTask.run(CraftTask.java:99) ~[patched_1.16.1.jar:git-Paper-135]
    at org.bukkit.craftbukkit.v1_16_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.16.1.jar:git-Paper-135]
    at net.minecraft.server.v1_16_R1.MinecraftServer.b(MinecraftServer.java:1298) ~[patched_1.16.1.jar:git-Paper-135]
    at net.minecraft.server.v1_16_R1.DedicatedServer.b(DedicatedServer.java:377) ~[patched_1.16.1.jar:git-Paper-135]
    at net.minecraft.server.v1_16_R1.MinecraftServer.a(MinecraftServer.java:1213) ~[patched_1.16.1.jar:git-Paper-135]
    at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:1001) ~[patched_1.16.1.jar:git-Paper-135]
    at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$a$0(MinecraftServer.java:177) ~[patched_1.16.1.jar:git-Paper-135]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]

Cause the exception from the registered listener prevented the rather codes from being executed, so updating task is keep calling the update() method of discarded instance.

MinusKube commented 4 years ago

Thanks :)