3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Use new JSONParsers or they all implode.

Dieser Commit ist enthalten in:
Myles 2016-03-03 23:40:09 +00:00
Ursprung 2704611977
Commit a42b113618

Datei anzeigen

@ -26,8 +26,6 @@ import java.util.*;
import static us.myles.ViaVersion.util.PacketUtil.*; import static us.myles.ViaVersion.util.PacketUtil.*;
public class OutgoingTransformer { public class OutgoingTransformer {
private static JSONParser parser = new JSONParser();
private final ConnectionInfo info; private final ConnectionInfo info;
private final ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance(); private final ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
private boolean cancel = false; private boolean cancel = false;
@ -240,7 +238,7 @@ public class OutgoingTransformer {
if (packet == PacketType.STATUS_RESPONSE) { if (packet == PacketType.STATUS_RESPONSE) {
String original = PacketUtil.readString(input); String original = PacketUtil.readString(input);
try { try {
JSONObject json = (JSONObject) parser.parse(original); JSONObject json = (JSONObject) new JSONParser().parse(original);
JSONObject version = (JSONObject) json.get("version"); JSONObject version = (JSONObject) json.get("version");
version.put("protocol", info.getProtocol()); version.put("protocol", info.getProtocol());
PacketUtil.writeString(json.toJSONString(), output); PacketUtil.writeString(json.toJSONString(), output);
@ -597,9 +595,9 @@ public class OutgoingTransformer {
line = "{\"text\":" + line + "}"; line = "{\"text\":" + line + "}";
} }
try { try {
parser.parse(line); new JSONParser().parse(line);
} catch (org.json.simple.parser.ParseException e) { } catch (Exception e) {
System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github!"); System.out.println("Invalid JSON String: \"" + line + "\" Please report this issue to the ViaVersion Github: " + e.getMessage());
return "{\"text\":\"\"}"; return "{\"text\":\"\"}";
} }
return line; return line;