TriumphTeam / triumph-gui

Simple lib to create inventory GUIs for Bukkit platforms.
MIT License
330 stars 57 forks source link

ItemBuilder not working in 1.20.6 #121

Closed xEcho1337 closed 3 months ago

xEcho1337 commented 3 months ago

Apparently when initializing an ItemBuilder the API tries to get the class CraftMetaItem, however in 1.20.6 it doesn't seem to exist. image

andrewkm commented 3 months ago

We are experiencing the same here, as are many others. https://github.com/tebexio/Tebex-Minecraft/issues/59

LichtHund commented 3 months ago

We are experiencing the same here, as are many others. https://github.com/tebexio/Tebex-Minecraft/issues/59

Hi, I have tested 3.1.10 on 1.20.6 and it is working fine. What could be causing issues here is versions conflict, try relocating triumph-gui so it doesn't cause any conflict with other plugins using older versions. If that doesn't solve the issue let me know and I'll look into it more.

andrewkm commented 3 months ago

We are experiencing the same here, as are many others. tebexio/Tebex-Minecraft#59

Hi, I have tested 3.1.10 on 1.20.6 and it is working fine. What could be causing issues here is versions conflict, try relocating triumph-gui so it doesn't cause any conflict with other plugins using older versions. If that doesn't solve the issue let me know and I'll look into it more.

That is not the case here.

We are using Paper version 1.21-38-master@1f5db50 & triumph-gui 3.1.10 This is a test with ONLY LuckPerms (compiled against https://github.com/LuckPerms/LuckPerms/commit/9e7a3d26e4992df88e9eb439fc2760c13ca2785e) and the Tebex-Minecraft plugin (compiled against https://github.com/tebexio/Tebex-Minecraft/commit/cd3b30dcabc77a4cd13516f1dcc339daadcbf187) with one minor private fork change to use triumph-gui 3.1.10

Issue: https://pastebin.com/raw/a57rf5ie PS: Same results on 1.20.6

Redned235 commented 3 months ago

It seems Tebex is using version 3.1.2 of Triumph GUI, so this is likely not an issue with this library.

We are using Paper version 1.21-38-master@1f5db50 & triumph-gui 3.1.10 This is a test with ONLY LuckPerms (compiled against LuckPerms/LuckPerms@9e7a3d2) and the Tebex-Minecraft plugin (compiled against tebexio/Tebex-Minecraft@cd3b30d) with one minor private fork change to use triumph-gui 3.1.10

Issue: pastebin.com/raw/a57rf5ie PS: Same results on 1.20.6

I suspect that you are not shading in the right version, since the line numbers in VersionHelper are not lining up with what is in 3.1.10 (they seem to line up with 3.1.2, so I suspect you are shading the wrong version in your fork).

The updated code in this library for the NMS package resolution works fine and is what Paper now recommends with their relocation changes. The previous code will have caused the issue you are seeing above, so I'd validate you are properly shading in the right version.

WildBamaBoy commented 3 months ago

Hi all, we're observing something a bit different (but possibly related) on the Tebex plugin https://github.com/tebexio/Tebex-Minecraft/issues/59

While on version 3.1.10 we see an UnsupportedOperationException from Adventure while trying to use Triumph's ItemBuilder with a lore component, so we don't know if it's either library or us that's the problem.

Where the lore component is something like this (unchanged between versions):

lore: [TextComponentImpl{content="Click to view packages!", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=false, color=NamedTextColor{name="gray", value="#aaaaaa"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]

The line in particular (among the other usages of ItemBuilder in this file): https://github.com/tebexio/Tebex-Minecraft/blob/2.0.5/bukkit/src/main/java/io/tebex/plugin/gui/BuyGUI.java#L126

Causes:

[13:09:33 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing 'buy' in io.tebex.plugin.command.BuyCommand(buy)
      [...]
Caused by: java.lang.UnsupportedOperationException
    at io.tebex.plugin.libs.kyori.adventure.platform.bukkit.MinecraftComponentSerializer.<clinit>(MinecraftComponentSerializer.java:101) ~[?:?]
    at io.tebex.plugin.libs.triumph.gui.builder.item.BaseItemBuilder.serializeComponent(BaseItemBuilder.java:109) ~[?:?]
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212) ~[?:?]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194) ~[?:?]
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709) ~[?:?]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556) ~[?:?]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546) ~[?:?]
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265) ~[?:?]
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:702) ~[?:?]
    at io.tebex.plugin.libs.triumph.gui.builder.item.BaseItemBuilder.lore(BaseItemBuilder.java:203) ~[?:?]
    at io.tebex.plugin.gui.BuyGUI.getCategoryItemBuilder(BuyGUI.java:142) ~[?:?]
    at io.tebex.plugin.gui.BuyGUI.lambda$open$1(BuyGUI.java:51) ~[?:?]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1597) ~[?:?]
    at io.tebex.plugin.gui.BuyGUI.open(BuyGUI.java:50) ~[?:?]
    at io.tebex.plugin.command.BuyCommand.execute(BuyCommand.java:25) ~[?:?]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:150) ~[spigot-api-1.20.6-R0.1-SNAPSHOT.jar:?]
    ... 26 more

This began on 1.20.6 and also affects 1.21.

andrewkm commented 3 months ago

It seems Tebex is using version 3.1.2 of Triumph GUI, so this is likely not an issue with this library.

We are using Paper version 1.21-38-master@1f5db50 & triumph-gui 3.1.10 This is a test with ONLY LuckPerms (compiled against LuckPerms/LuckPerms@9e7a3d2) and the Tebex-Minecraft plugin (compiled against tebexio/Tebex-Minecraft@cd3b30d) with one minor private fork change to use triumph-gui 3.1.10 Issue: pastebin.com/raw/a57rf5ie PS: Same results on 1.20.6

I suspect that you are not shading in the right version, since the line numbers in VersionHelper are not lining up with what is in 3.1.10 (they seem to line up with 3.1.2, so I suspect you are shading the wrong version in your fork).

The updated code in this library for the NMS package resolution works fine and is what Paper now recommends with their relocation changes. The previous code will have caused the issue you are seeing above, so I'd validate you are properly shading in the right version.

Thanks for catching this. My Jenkins job was setup slightly wrong. It looks like the original issue is fixed in 3.1.10, but we've now got yet another problem going on: https://github.com/tebexio/Tebex-Minecraft/issues/59#issuecomment-2197513665

[15:32:58] [Server thread/ERROR]: Command exception: /buy
java.lang.UnsupportedOperationException: null
    at tebex-bukkit-2.0.6-prerelease.jar/io.tebex.plugin.libs.kyori.adventure.platform.bukkit.MinecraftComponentSerializer.<clinit>(MinecraftComponentSerializer.java:101) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at tebex-bukkit-2.0.6-prerelease.jar/dev.triumphteam.gui.builder.item.BaseItemBuilder.serializeComponent(BaseItemBuilder.java:109) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at tebex-bukkit-2.0.6-prerelease.jar/dev.triumphteam.gui.builder.item.BaseItemBuilder.name(BaseItemBuilder.java:148) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at tebex-bukkit-2.0.6-prerelease.jar/io.tebex.plugin.gui.BuyGUI.getCategoryItemBuilder(BuyGUI.java:125) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at tebex-bukkit-2.0.6-prerelease.jar/io.tebex.plugin.gui.BuyGUI.lambda$open$1(BuyGUI.java:50) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1597) ~[?:?]
    at tebex-bukkit-2.0.6-prerelease.jar/io.tebex.plugin.gui.BuyGUI.open(BuyGUI.java:49) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at tebex-bukkit-2.0.6-prerelease.jar/io.tebex.plugin.command.BuyCommand.execute(BuyCommand.java:25) ~[tebex-bukkit-2.0.6-prerelease.jar:?]
    at io.papermc.paper.command.brigadier.bukkit.BukkitCommandNode$BukkitBrigCommand.run(BukkitCommandNode.java:91) ~[paper-1.21.jar:1.21-38-1f5db50]
    at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?]
    at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:31) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.execution.tasks.ExecuteCommand.execute(ExecuteCommand.java:19) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.execution.UnboundEntryAction.lambda$bind$0(UnboundEntryAction.java:8) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.execution.CommandQueueEntry.execute(CommandQueueEntry.java:5) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.execution.ExecutionContext.runCommandQueue(ExecutionContext.java:103) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.Commands.executeCommandInContext(Commands.java:446) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.Commands.performCommand(Commands.java:353) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.Commands.performCommand(Commands.java:340) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.commands.Commands.performCommand(Commands.java:335) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.performUnsignedChatCommand(ServerGamePacketListenerImpl.java:2147) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$11(ServerGamePacketListenerImpl.java:2121) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:151) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1478) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:201) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:125) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1456) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1449) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:135) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1408) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1415) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1260) ~[paper-1.21.jar:1.21-38-1f5db50]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[paper-1.21.jar:1.21-38-1f5db50]
    at java.base/java.lang.Thread.run(Thread.java:1570) ~[?:?]
LichtHund commented 3 months ago

Hi all, we're observing something a bit different (but possibly related) on the Tebex plugin https://github.com/tebexio/Tebex-Minecraft/issues/59

While on version 3.1.10 we see an UnsupportedOperationException from Adventure while trying to use Triumph's ItemBuilder with a lore component, so we don't know if it's either library or us that's the problem.

Where the lore component is something like this (unchanged between versions):

lore: [TextComponentImpl{content="Click to view packages!", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=false, color=NamedTextColor{name="gray", value="#aaaaaa"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]

The line in particular (among the other usages of ItemBuilder in this file): https://github.com/tebexio/Tebex-Minecraft/blob/2.0.5/bukkit/src/main/java/io/tebex/plugin/gui/BuyGUI.java#L126

Causes:

[13:09:33 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing 'buy' in io.tebex.plugin.command.BuyCommand(buy)
      [...]
Caused by: java.lang.UnsupportedOperationException
  at io.tebex.plugin.libs.kyori.adventure.platform.bukkit.MinecraftComponentSerializer.<clinit>(MinecraftComponentSerializer.java:101) ~[?:?]
  at io.tebex.plugin.libs.triumph.gui.builder.item.BaseItemBuilder.serializeComponent(BaseItemBuilder.java:109) ~[?:?]
  at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:212) ~[?:?]
  at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:194) ~[?:?]
  at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1709) ~[?:?]
  at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:556) ~[?:?]
  at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:546) ~[?:?]
  at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[?:?]
  at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265) ~[?:?]
  at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:702) ~[?:?]
  at io.tebex.plugin.libs.triumph.gui.builder.item.BaseItemBuilder.lore(BaseItemBuilder.java:203) ~[?:?]
  at io.tebex.plugin.gui.BuyGUI.getCategoryItemBuilder(BuyGUI.java:142) ~[?:?]
  at io.tebex.plugin.gui.BuyGUI.lambda$open$1(BuyGUI.java:51) ~[?:?]
  at java.base/java.util.ArrayList.forEach(ArrayList.java:1597) ~[?:?]
  at io.tebex.plugin.gui.BuyGUI.open(BuyGUI.java:50) ~[?:?]
  at io.tebex.plugin.command.BuyCommand.execute(BuyCommand.java:25) ~[?:?]
  at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:150) ~[spigot-api-1.20.6-R0.1-SNAPSHOT.jar:?]
  ... 26 more

This began on 1.20.6 and also affects 1.21.

Heyo, sorry for the delay, I'll only be able to take a good look at it Tuesday.

LichtHund commented 3 months ago

@WildBamaBoy this was a fun ride, I tested it in many ways, even had a plugin that was producing the exact same component as Tebex, Tebex would error while the test plugin wouldn't. But good news I have found the issue, it's caused by relocating GSON. Adventure bukkit platform's MinecraftComponentSerializer relies on reflection to get GSON methods, which when relocating it was not able to find. Thankfully you should not need to either shade nor relocate GSON, the version provided by the server jar should be all you need, so you can remove the relocation and exclude GSON from triumph-gui. In future releases I'll make sure to exclude it from the lib itself so these steps won't be needed. These were the changes:

diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts
index 245f366..be42623 100644
--- a/bukkit/build.gradle.kts
+++ b/bukkit/build.gradle.kts
@@ -7,7 +7,9 @@ dependencies {
     implementation(project(":sdk"))
     implementation("it.unimi.dsi:fastutil:8.5.6")
     implementation("com.github.cryptomorin:XSeries:9.3.1") { isTransitive = false }
-    implementation("dev.triumphteam:triumph-gui:3.1.2")
+    implementation("dev.triumphteam:triumph-gui:3.1.10") {
+        exclude("com.google.gson")
+    }

     compileOnly("org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT")
     compileOnly("dev.dejvokep:boosted-yaml:1.3")
@@ -20,12 +22,12 @@ tasks.named("shadowJar", ShadowJar::class.java) {
     relocate("it.unimi", "io.tebex.plugin.libs.fastutil")
     relocate("okhttp3", "io.tebex.plugin.libs.okhttp3")
     relocate("net.kyori", "io.tebex.plugin.libs.kyori")
+    relocate("dev.triumphteam", "io.tebex.plugin.libs.gui")
     relocate("okio", "io.tebex.plugin.libs.okio")
     relocate("dev.dejvokep.boostedyaml", "io.tebex.plugin.libs.boostedyaml")
     relocate("org.jetbrains.annotations", "io.tebex.plugin.libs.jetbrains")
     relocate("kotlin", "io.tebex.plugin.libs.kotlin")
     relocate("com.github.benmanes.caffeine", "io.tebex.plugin.libs.caffeine")
-    relocate("com.google.gson", "io.tebex.plugin.libs.gson")
     minimize()
 }
WildBamaBoy commented 3 months ago

Thanks for your help @LichtHund , confirming that this works on our end as well.