Unable to parse Malformed Json!
Realmm opened this issue ยท 2 comments
When instantiating in 1.17, an NBTContainer with a string, (I used the string "test-sword"), I get an error from the ReflectionUtil
The NBTContainer is instantied with new NBTContainer("test-sword")
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.nbtapi.NBTContainer.<init>(NBTContainer.java:68)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.token.TokenModel.load(TokenModel.java:190)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.token.TokenManager.lambda$loadTokens$0(TokenManager.java:130)
[08:53:10] [Server thread/WARN]: at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.token.TokenManager.loadTokens(TokenManager.java:123)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.MetaCity.setUp(MetaCity.java:89)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.MetaCity.onEnable(MetaCity.java:37)
[08:53:10] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263)
[08:53:10] [Server thread/WARN]: at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342)
[08:53:10] [Server thread/WARN]: at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480)
[08:53:10] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:495)
[08:53:10] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:409)
[08:53:10] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:607)
[08:53:10] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:264)
[08:53:10] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:986)
[08:53:10] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:307)
[08:53:10] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:831)
[08:53:10] [Server thread/WARN]: Caused by: org.metacity.metacity.nbtapi.NbtApiException: Error while calling the method 'parse', loaded: true, Enum: PARSE_NBT
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:164)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.nbtapi.NBTContainer.<init>(NBTContainer.java:66)
[08:53:10] [Server thread/WARN]: ... 16 more
[08:53:10] [Server thread/WARN]: Caused by: java.lang.reflect.InvocationTargetException
[08:53:10] [Server thread/WARN]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[08:53:10] [Server thread/WARN]: at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
[08:53:10] [Server thread/WARN]: at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[08:53:10] [Server thread/WARN]: at java.base/java.lang.reflect.Method.invoke(Method.java:567)
[08:53:10] [Server thread/WARN]: at org.metacity.metacity.nbtapi.utils.nmsmappings.ReflectionMethod.run(ReflectionMethod.java:162)
[08:53:10] [Server thread/WARN]: ... 17 more
[08:53:10] [Server thread/WARN]: Caused by: com.mojang.brigadier.exceptions.CommandSyntaxException: Expected '{' at position 0: <--[HERE]
The constructor NBTContainer(String nbtString)
at https://github.com/tr7zw/Item-NBT-API/blob/master/item-nbt-api/src/main/java/de/tr7zw/changeme/nbtapi/NBTContainer.java#L60-L70 seems to expect a stringified JSON object. So for example {"id": "test"}
would be valid. Just any string, like your "test-sword"
is simply not valid JSON.
Yea basically. test-sword
is not valid json so it doesn't work.
Valid Mojang json looks something like this (just clicked some stuff together on a Minecraft item generator): {CustomModelData:42,EntityTag:{Invisible:1b},display:{Name:'[{"text":"somename","italic":false}]',Lore:['[{"text":"test","italic":false}]','[{"text":"test2","italic":false}]']},Enchantments:[{id:aqua_affinity,lvl:1},{id:channeling,lvl:1}],HideFlags:3}