NBT-API

NBT-API

98.9k Downloads

Error with 1.20.1 getting NBT string

Smudgge opened this issue ยท 3 comments

commented
Plugin Version: 2.11.3
Server Version: 1.20.1
Java: 19.0.2

This is the code I am using to test if a book has the nbt key "book".

NBTItem nbt = new NBTItem(itemStack);
if (nbt.getString("book") == null) return false;    // <-- ReplaceItem.java:50

return !Objects.equals(nbt.getString("book"), "");

This is the reduced error

Caused by: SmTrackerFix.NbtApiException: [?]Error while calling the method 'getString(java.lang.String)', loaded: true, Enum: COMPOUND_GET_STRING Passed Class: class java.lang.Boolean
        at SmTrackerFix.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:185) ~[SmReplacer-1.6.0.jar:?]
        at SmTrackerFix.NBTReflectionUtil.getData(NBTReflectionUtil.java:631) ~[SmReplacer-1.6.0.jar:?]
        at SmTrackerFix.NBTCompound.getString(NBTCompound.java:118) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.objects.ReplaceItem.isAE(ReplaceItem.java:50) ~[SmReplacer-1.6.0.jar:?]

This is the console error

org.bukkit.command.CommandException: Unhandled exception executing command 'replace' in plugin SmReplacer v1.6.0
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:933) ~[paper-1.20.1.jar:git-Paper-39]
        at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.20.1.jar:git-Paper-39]
        at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[paper-1.20.1.jar:?]
        at net.minecraft.commands.Commands.performCommand(Commands.java:324) ~[?:?]
        at net.minecraft.commands.Commands.performCommand(Commands.java:308) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2298) ~[?:?]
        at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2258) ~[?:?]
        at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1339) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1316) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1309) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1287) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1175) ~[paper-1.20.1.jar:git-Paper-39]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-39]
        at java.lang.Thread.run(Thread.java:1589) ~[?:?]
Caused by: SmTrackerFix.NbtApiException: [?]Error while calling the method 'getString(java.lang.String)', loaded: true, Enum: COMPOUND_GET_STRING Passed Class: class java.lang.Boolean
        at SmTrackerFix.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:185) ~[SmReplacer-1.6.0.jar:?]
        at SmTrackerFix.NBTReflectionUtil.getData(NBTReflectionUtil.java:631) ~[SmReplacer-1.6.0.jar:?]
        at SmTrackerFix.NBTCompound.getString(NBTCompound.java:118) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.objects.ReplaceItem.isAE(ReplaceItem.java:50) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.commands.subcommands.replace.Books.executeCommand(Books.java:72) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.commands.CommandHandler.onCommand(CommandHandler.java:78) ~[SmReplacer-1.6.0.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
        at jdk.internal.reflect.DirectMethodHandleAccessor.checkReceiver(DirectMethodHandleAccessor.java:202) ~[?:?]
        at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:100) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:578) ~[?:?]
        at SmTrackerFix.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:183) ~[SmReplacer-1.6.0.jar:?]
        at SmTrackerFix.NBTReflectionUtil.getData(NBTReflectionUtil.java:631) ~[SmReplacer-1.6.0.jar:?]
        at SmTrackerFix.NBTCompound.getString(NBTCompound.java:118) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.objects.ReplaceItem.isAE(ReplaceItem.java:50) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.commands.subcommands.replace.Books.executeCommand(Books.java:72) ~[SmReplacer-1.6.0.jar:?]
        at me.smudge.smreplacer.commands.CommandHandler.onCommand(CommandHandler.java:78) ~[SmReplacer-1.6.0.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        ... 23 more
commented

Make sure you are actually shading version 2.11.3. That looks a lot like using an outdated version.

commented

Wait I think its because I shaded it, yeah :,)
Ill see if it works now

commented

Woop, it was the shade, thanks for your help!