1.16.5 ComponentSerializer throwing error on 1.16

Discussion in 'Spigot Plugin Development' started by LOOHP, Jun 25, 2020.

Thread Status:
Not open for further replies.
  1. Hello! As I was updating my plugin to 1.16 I ran into this problem.

    While trying to parse a Json String into BaseComponents using the ComponentSerializer, some Json Strings involving the translatable component throws error.

    This is one of the examples, which is generated by the game whenever a player switches gamemode. Which means it should be error free.
    Code (Text):
    {"italic":true,"color":"gray","translate":"chat.type.admin","with":[{"text":"Server"},{"translate":"commands.gamemode.success.other","with":[{"insertion":"AppLEshakE","clickEvent":{"action":"suggest_command","value":"/tell AppLEshakE "},"hoverEvent":{"action":"show_entity","contents":{"type":"minecraft:player","id":"5e094b95-bcc1-4067-81ac-8b279345902b","name":{"text":"AppLEshakE"}}},"text":"AppLEshakE"},{"translate":"gameMode.creative"}]}]}
    At this line of code, error is thrown
    Code (Java):
    ComponentSerializer.parse(json);
    Error
    Code (Text):
    [22:57:48] [Server thread/WARN]: java.lang.NullPointerException
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.BaseComponentSerializer.deserialize(BaseComponentSerializer.java:70)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.TextComponentSerializer.deserialize(TextComponentSerializer.java:23)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.TextComponentSerializer.deserialize(TextComponentSerializer.java:15)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:887)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:952)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:91)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:20)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:887)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:952)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.TranslatableComponentSerializer.deserialize(TranslatableComponentSerializer.java:27)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.TranslatableComponentSerializer.deserialize(TranslatableComponentSerializer.java:15)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:887)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:952)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:77)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:20)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:887)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:952)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.TranslatableComponentSerializer.deserialize(TranslatableComponentSerializer.java:27)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.TranslatableComponentSerializer.deserialize(TranslatableComponentSerializer.java:15)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:887)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:952)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:77)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:20)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:887)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:952)
    [22:57:48] [Server thread/WARN]:        at com.google.gson.Gson.fromJson(Gson.java:925)
    [22:57:48] [Server thread/WARN]:        at net.md_5.bungee.chat.ComponentSerializer.parse(ComponentSerializer.java:46)
    [22:57:48] [Server thread/WARN]:        at com.loohp.interactivechat.Listeners.ChatPackets$1.onPacketSending(ChatPackets.java:90)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.SortedPacketListenerList.invokeSendingListener(SortedPacketListenerList.java:195)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.SortedPacketListenerList.invokePacketSending(SortedPacketListenerList.java:149)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.PacketFilterManager.handlePacket(PacketFilterManager.java:588)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.PacketFilterManager.invokePacketSending(PacketFilterManager.java:564)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ProtocolInjector.packetQueued(ProtocolInjector.java:338)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ProtocolInjector.onPacketSending(ProtocolInjector.java:298)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ChannelInjector.processSending(ChannelInjector.java:378)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ChannelInjector.access$800(ChannelInjector.java:64)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ChannelInjector$3.handleScheduled(ChannelInjector.java:343)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ChannelInjector$3.onMessageScheduled(ChannelInjector.java:313)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.ChannelProxy$2.schedulingRunnable(ChannelProxy.java:127)
    [22:57:48] [Server thread/WARN]:        at com.comphenix.protocol.injector.netty.EventLoopProxy.execute(EventLoopProxy.java:95)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.NetworkManager.b(NetworkManager.java:184)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.NetworkManager.sendPacket(NetworkManager.java:154)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.PlayerConnection.a(PlayerConnection.java:1456)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.EntityPlayer.a(EntityPlayer.java:1540)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.EntityPlayer.sendMessage(EntityPlayer.java:1536)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.CommandListenerWrapper.sendAdminMessage(CommandListenerWrapper.java:204)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.CommandListenerWrapper.sendMessage(CommandListenerWrapper.java:189)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.CommandGamemode.a(CommandGamemode.java:44)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.CommandGamemode.a(CommandGamemode.java:64)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.CommandGamemode.lambda$2(CommandGamemode.java:26)
    [22:57:48] [Server thread/WARN]:        at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:262)
    [22:57:48] [Server thread/WARN]:        at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:176)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.CommandDispatcher.a(CommandDispatcher.java:180)
    [22:57:48] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R1.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:45)
    [22:57:48] [Server thread/WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149)
    [22:57:48] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R1.CraftServer.dispatchCommand(CraftServer.java:748)
    [22:57:48] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_16_R1.CraftServer.dispatchServerCommand(CraftServer.java:733)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.DedicatedServer.handleCommandQueue(DedicatedServer.java:386)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.DedicatedServer.b(DedicatedServer.java:355)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.MinecraftServer.a(MinecraftServer.java:1010)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.MinecraftServer.v(MinecraftServer.java:849)
    [22:57:48] [Server thread/WARN]:        at net.minecraft.server.v1_16_R1.MinecraftServer.lambda$0(MinecraftServer.java:165)
    [22:57:48] [Server thread/WARN]:        at java.lang.Thread.run(Unknown Source)

    Thanks in advance!
     
    #1 LOOHP, Jun 25, 2020
    Last edited: Jun 25, 2020
    • Like Like x 1
  2. Is it due to the new content field they introduced in 1.16 ?
     
  3. Yeah and also because the Gson used by Bungee/Spigot for deserializing components never implemented show_entity before
     
  4. I see, thanks!
     
Thread Status:
Not open for further replies.