From 7831dc0082a4b19515ad320f59f29ee31f18fc61 Mon Sep 17 00:00:00 2001 From: Mats Date: Tue, 1 Mar 2016 14:25:26 +0100 Subject: [PATCH] Fix MalformedJsonException on Kick / Disconnect --- .../ViaVersion/transformers/OutgoingTransformer.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index 4a293ecc6..0121652b2 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -25,6 +25,9 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.*; +import static us.myles.ViaVersion.PacketUtil.readString; +import static us.myles.ViaVersion.PacketUtil.writeString; + public class OutgoingTransformer { private static Gson gson = new Gson(); private final Channel channel; @@ -78,6 +81,13 @@ public class OutgoingTransformer { output.writeInt(target); return; } + if (packet == PacketType.PLAY_DISCONNECT){ + String reason = readString(input); + if (reason.startsWith("\"")) + reason = "{\"text\":" + reason + "}"; + writeString(reason,output); + return; + } if (packet == PacketType.PLAY_ENTITY_TELEPORT) { // Port this so that it relative moves :P int id = PacketUtil.readVarInt(input);