Incendo / cloud-minecraft

Integrations between Minecraft and Cloud Command Framework
https://cloud.incendo.org/minecraft/
MIT License
27 stars 8 forks source link

[Bug] ItemStackParser not working on 1.20.6 #69

Closed Xiao-MoMi closed 5 months ago

Xiao-MoMi commented 5 months ago

Tested on Paper version git-Paper-78 (MC: 1.20.6)

java.lang.ExceptionInInitializerError: null
        at net.momirealms.sparrow.libraries.cloud.bukkit.parser.ItemStackParser.<init>(ItemStackParser.java:118) ~[?:?]
        at net.momirealms.sparrow.libraries.cloud.bukkit.parser.ItemStackParser.itemStackParser(ItemStackParser.java:80) ~[?:?]
        at net.momirealms.sparrow.libraries.cloud.bukkit.BukkitCommandManager.<init>(BukkitCommandManager.java:131) ~[?:?]
        at net.momirealms.sparrow.libraries.cloud.paper.PaperCommandManager.<init>(PaperCommandManager.java:84) ~[?:?]
        at net.momirealms.sparrow.bukkit.command.SparrowBukkitCommandManager.<init>(SparrowBukkitCommandManager.java:114) ~[?:?]
        at net.momirealms.sparrow.bukkit.SparrowBukkitPlugin.setupCommandManager(SparrowBukkitPlugin.java:75) ~[?:?]
        at net.momirealms.sparrow.common.plugin.AbstractSparrowPlugin.enable(AbstractSparrowPlugin.java:36) ~[?:?]
        at net.momirealms.sparrow.bukkit.SparrowBukkitPlugin.enable(SparrowBukkitPlugin.java:52) ~[?:?]
        at net.momirealms.sparrow.bukkit.SparrowBukkitBootstrap.onEnable(SparrowBukkitBootstrap.java:144) ~[?:?]
        at Sparrow-Paper-1.5.0-f5484293.jar/net.momirealms.sparrow.paper.loader.PaperLoaderPlugin.onEnable(PaperLoaderPlugin.java:26) ~[Sparrow-Paper-1.5.0-f5484293.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:202) ~[paper-1.20.6.jar:git-Paper-78]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.20.6.jar:git-Paper-78]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:519) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:609) ~[paper-1.20.6.jar:git-Paper-78]
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:558) ~[paper-1.20.6.jar:git-Paper-78]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:681) ~[paper-1.20.6.jar:git-Paper-78]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:440) ~[paper-1.20.6.jar:git-Paper-78]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:323) ~[paper-1.20.6.jar:git-Paper-78]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1142) ~[paper-1.20.6.jar:git-Paper-78]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:326) ~[paper-1.20.6.jar:git-Paper-78]        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Couldn't find tag field on ItemInput
        at net.momirealms.sparrow.libraries.cloud.bukkit.internal.CraftBukkitReflection.firstNonNullOrThrow(CraftBukkitReflection.java:92) ~[?:?]
        at net.momirealms.sparrow.libraries.cloud.bukkit.parser.ItemStackParser$ModernParser.<clinit>(ItemStackParser.java:169) ~[?:?]
        ... 22 more

After decompiling the server and comparing the difference, I found that the field "tag" no longer exists, thus causing the error [1.20.4] 1 20 4 [1.20.6] 1 20 6

jpenilla commented 5 months ago

I can't reproduce this issue. tag is used as a fallback for <=1.20.4 Mojang mapped servers. The target field is still named c on spigot and modern Paper will remap the reflection.

Xiao-MoMi commented 5 months ago

Tested with spigot 1.20.6 and it's working as expected. Could it be problem that the field is "components" instead of "tag" in 1.20.6 mojang mapped server.

1.20.6 spigot image

jpenilla commented 5 months ago

No, that isn't a problem. My testing was on Paper as well. There must be something strange with your environment.

Xiao-MoMi commented 5 months ago

After creating a new plugin and shading the cloud into the jar, I found it's working well on 1.20.6 paper. The only difference is that I was using a JarInJarClassLoader as you can see in the screenshot below image Is there anyway to fix that? As it works fine both on 1.20.4 and 1.20.4 mojang mapping servers but not work on 1.20.6 paper

jpenilla commented 5 months ago

You should add the jar to the classpath using supported api like the PluginLoader or even spigots library downloader. Otherwise you need to apply reflection and bytecode remapping yourself. I can add the new name to the search list later, but you should really adjust how you load the inner jar on Paper.

Xiao-MoMi commented 5 months ago

Thanks! Have a good day