OvercastNetwork / SportBukkit

CraftBukkit and Bukkit modifications that improve stability and add new features
99 stars 84 forks source link

ProtocolInjector.PacketTabHeader(String, String) how can i fix it? #153

Closed OrigamiDream closed 9 years ago

OrigamiDream commented 9 years ago

I coded some source. the 1.8 tablist IChatBaseComponent Header = ChatSerializer.a("{'text': 'Test Network', 'color': 'aqua', 'bold': 'true'}"); IChatBaseComponent Footer = ChatSerializer.a("{'text': 'Footer', 'color': 'white', 'bold': true}"); // This codes are not error. PlayerConnection C = ((CraftPlayer) player).getHandle().playerConnection; C.sendPacket(new ProtocolInjector.PacketTabHeader(Header, Footer)); <- Error

so I tried another codes. C.sendPacket(new ProtocolInjector.PacketTabHeader(Header.toString(), Footer.toString())); <- Error C.sendPacket(new ProtocolInjector.PacketTabHeader(Header + "", Footer + "")); <- Error C.sendPacket(new ProtocolInjector.PacketTabHeader(SpigotComponentReverter.toLegacy(Header), SpigotComponentReverter.toLegacy(Footer))); <- Error C.sendPacket(new ProtocolInjector.PacketTabHeader("Test Network", "Footer")); <- Error C.sendPacket(new ProtocolInjector.PacketTabHeader("{'text': 'Test Network', 'color': 'aqua', 'bold': 'true'}", "{'text': 'Footer', 'color': 'white', 'bold': true}")); <- Error When I join the server, I kick for reason: ''Internal Exception: io.netty.handler.codec.DecoderException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 12"

I 'm using SportBukkit 1.7.10 Last Build. (because my server should suppport 1.7.~ 1.8.

Can you help me??

TheMolkaPL commented 9 years ago

Just use double quotes istead of single.

{"text": "Test Network", "color": "aqua", "bold": true}
{"text": "Footer", "color": "white", "bold": true}

In Java should be:

IChatBaseComponent Header = ChatSerializer.a("{\"text\": \"Test Network\", \"color\": \"aqua\", \"bold\": \"true\"}");
IChatBaseComponent Footer= ChatSerializer.a("{\"text\": \"Footer\", \"color\": \"white\", \"bold\": true}");

Also try JSON validator with problems with JSON.

twizmwazin commented 9 years ago

You are running an old version of SporrtBukkit, I suggest updating to the most recent build.