Bounser / Nascraft

An alternative economy with dynamic prices based on supply and demand.
https://www.spigotmc.org/resources/108216/
MIT License
7 stars 1 forks source link

Crash of the plugin when deleting categories #7

Closed Zekariaa closed 5 months ago

Zekariaa commented 5 months ago

Hello, When deleting multiples categories, it seems like the plugin crash every time I delete the last third categories. Here is the crash log. After this i'm unable to use the plugin and have to reset my configs.

[12:49:38 ERROR]: Could not pass event InventoryClickEvent to Nascraft v1.5.1
java.lang.IndexOutOfBoundsException: Index 3 out of bounds for length 3
        at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
        at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
        at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
        at java.util.Objects.checkIndex(Objects.java:361) ~[?:?]
        at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
        at me.bounser.nascraft.commands.admin.marketeditor.overview.MarketEditor.insertItems(MarketEditor.java:164) ~[Nascraft-1.5.1.jar:?]
        at me.bounser.nascraft.commands.admin.marketeditor.overview.MarketEditor.open(MarketEditor.java:44) ~[Nascraft-1.5.1.jar:?]
        at me.bounser.nascraft.commands.admin.marketeditor.overview.MarketEditor.<init>(MarketEditor.java:34) ~[Nascraft-1.5.1.jar:?]
        at me.bounser.nascraft.commands.admin.marketeditor.overview.MarketEditorManager.startEditing(MarketEditorManager.java:16) ~[Nascraft-1.5.1.jar:?]
        at me.bounser.nascraft.commands.admin.marketeditor.edit.category.CategoryEditor.removeCategory(CategoryEditor.java:200) ~[Nascraft-1.5.1.jar:?]
        at me.bounser.nascraft.commands.admin.marketeditor.edit.category.CategoryEditorListener.onClickInventory(CategoryEditorListener.java:59) ~[Nascraft-1.5.1.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor543.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[?:git-UniverseSpigot-"2c2ab74"]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:76) ~[?:git-UniverseSpigot-"2c2ab74"]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[?:git-UniverseSpigot-"2c2ab74"]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:76) ~[?:git-UniverseSpigot-"2c2ab74"]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[?:git-UniverseSpigot-"2c2ab74"]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:617) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleContainerClick(ServerGamePacketListenerImpl.java:3135) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:58) ~[?:?]
        at net.minecraft.network.protocol.game.ServerboundContainerClickPacket.handle(ServerboundContainerClickPacket.java:25) ~[?:?]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:53) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:148) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1474) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:196) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:122) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1451) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1379) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:132) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1357) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1246) ~[?:git-UniverseSpigot-"2c2ab74"]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[?:git-UniverseSpigot-"2c2ab74"]
        at java.lang.Thread.run(Thread.java:840) ~[?:?]

Thank you, have a good one mate

Bounser commented 5 months ago

Hello! First of all I would recommend not reloading the plugin with /reload nor third party plugins, as it is not a reliable at all. I would recommend restarting instead. Apart from that, it seems to be indeed a problem with the editmarket command that I will have to look into. In the meantime to delete these categories you might want to go and remove them manually from items.yml and categories.yml. Sorry for the inconvenience.

Zekariaa commented 5 months ago

Hello! I hope you are doing well!! I removed them manually, but it made the same error after restarting. Do you have any idea why it would make this error ?

But overall, thank you mate! The plugin is incredible, I really think it has a great potential, it should be a paid resource 🥇

EDIT: My bad. It's because I need 4 categories to get the plugin to run. Sorry for my misunderstanding

Bounser commented 5 months ago

Yeah, with less than three categories AdvancedGUI's layout wouldn't work. In the next version I will add a warning when you have less than three categories and just disable the layout extension or adapt the GUI so it works. Thanks for your feedback and support! I really appreciate it.