Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Merge pull request #77 from HugoDaBosss/patch-2
Don't send malformed JSON anymore, preventing kicks.
Dieser Commit ist enthalten in:
Commit
615b9f847c
@ -2,10 +2,14 @@ package us.myles.ViaVersion.transformers;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.spacehq.mc.protocol.data.game.chunk.Column;
|
import org.spacehq.mc.protocol.data.game.chunk.Column;
|
||||||
import org.spacehq.mc.protocol.util.NetUtil;
|
import org.spacehq.mc.protocol.util.NetUtil;
|
||||||
|
|
||||||
import us.myles.ViaVersion.CancelException;
|
import us.myles.ViaVersion.CancelException;
|
||||||
import us.myles.ViaVersion.ConnectionInfo;
|
import us.myles.ViaVersion.ConnectionInfo;
|
||||||
import us.myles.ViaVersion.ViaVersionPlugin;
|
import us.myles.ViaVersion.ViaVersionPlugin;
|
||||||
@ -492,6 +496,13 @@ public class OutgoingTransformer {
|
|||||||
if (line.startsWith("\""))
|
if (line.startsWith("\""))
|
||||||
line = "{\"text\":" + line + "}";
|
line = "{\"text\":" + line + "}";
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
new JSONParser().parse(line);
|
||||||
|
}
|
||||||
|
catch (org.json.simple.parser.ParseException e) {
|
||||||
|
System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github!");
|
||||||
|
return "{\"text\":\"\"}";
|
||||||
|
}
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren