emanondev / ItemEdit

GNU General Public License v3.0
15 stars 14 forks source link

Cannot edit `minecraft:light_gray_banner` #19

Closed SKevo18 closed 8 months ago

SKevo18 commented 8 months ago
[06.01 18:35:43] [Server] [ERROR] null
[06.01 18:35:43] [Server] org.bukkit.command.CommandExceptionUnhandled exception executing command 'ie' in plugin ItemEdit v3.1.5
[06.01 18:35:43] [Server]   at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
[06.01 18:35:43] [Server]   at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
[06.01 18:35:43] [Server]   at org.bukkit.craftbukkit.v1_20_R3.CraftServer.dispatchCommand(CraftServer.java:987) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at org.bukkit.craftbukkit.v1_20_R3.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?]
[06.01 18:35:43] [Server]   at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:32) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:19) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.commands.execution.CommandQueueEntry.a(CommandQueueEntry.java:5) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:101) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:435) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.commands.Commands.performCommand(Commands.java:336) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.commands.Commands.performCommand(Commands.java:323) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2234) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$16(ServerGamePacketListenerImpl.java:2194) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
[06.01 18:35:43] [Server]   at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1458) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:194) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1435) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1358) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1509) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1214) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[paper-1.20.4.jar:git-Paper-378]
[06.01 18:35:43] [Server]   at java.lang.Thread.run(Thread.java:833) ~[?:?]
[06.01 18:35:43] [Server] Caused byjava.lang.IllegalArgumentException: No enum constant org.bukkit.Material.INK_SACK
[06.01 18:35:43] [Server]   at java.lang.Enum.valueOf(Enum.java:273) ~[?:?]
[06.01 18:35:43] [Server]   at org.bukkit.Material.valueOf(Material.java:124) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.Util.getDyeItemFromColor(Util.java:242) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.gui.BannerEditor.updateInventory(BannerEditor.java:215) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.gui.BannerEditor.<init>(BannerEditor.java:134) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.command.itemedit.Banner.onCommand(Banner.java:38) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.command.AbstractCommand.onCommand(AbstractCommand.java:57) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
[06.01 18:35:43] [Server]   ... more

This error occurs only when editing light_gray_banner, other banners seem to be unaffected. The relevant log lines seem to be:

Caused byjava.lang.IllegalArgumentException: No enum constant org.bukkit.Material.INK_SACK
[06.01 18:35:43] [Server]   at java.lang.Enum.valueOf(Enum.java:273) ~[?:?]
[06.01 18:35:43] [Server]   at org.bukkit.Material.valueOf(Material.java:124) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.Util.getDyeItemFromColor(Util.java:242) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.gui.BannerEditor.updateInventory(BannerEditor.java:215) ~[ItemEdit-3.1.5.jar:?]
[06.01 18:35:43] [Server]   at emanondev.itemedit.gui.BannerEditor.<init>(BannerEditor.java:134) ~[ItemEdit-3.1.5.jar:?]

Relevant code seems to be:

https://github.com/emanondev/ItemEdit/blob/98cf6bc77ac7352d5a0cad8219831739157b1c4f/src/main/java/emanondev/itemedit/gui/BannerEditor.java#L209-L215

This seems to happen because the code that determines the banner color uses the first string before _ as a dye color. But light_gray_banner would have color light (because that's the first thing in an array of split _ strings), and light color does not exist. So, it fall backs to pre-1.13 materials, where INK_SAC was used as a dye, but I am running 1.20.4 (which uses its own BLACK_DYE instead).

I'd suggest stripping _banner from the material name instead to determine the color. That means that this also works for things like light_gray (light_gray_dye is a valid material).

emanondev commented 8 months ago

Should be solved, thanks for your very detailed report :)