Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Print erroneous json if parsing fails
Dieser Commit ist enthalten in:
Ursprung
c326bb7b51
Commit
89c503dd92
@ -3,6 +3,8 @@ package us.myles.ViaVersion.api.rewriters;
|
|||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
import us.myles.ViaVersion.api.protocol.ClientboundPacketType;
|
||||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||||
@ -99,9 +101,14 @@ public class ComponentRewriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JsonElement processText(String value) {
|
public JsonElement processText(String value) {
|
||||||
JsonElement root = GsonUtil.getJsonParser().parse(value);
|
try {
|
||||||
processText(root);
|
JsonElement root = GsonUtil.getJsonParser().parse(value);
|
||||||
return root;
|
processText(root);
|
||||||
|
return root;
|
||||||
|
} catch (JsonSyntaxException e) {
|
||||||
|
Via.getPlatform().getLogger().severe("Error when trying to parse json: " + value);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processText(JsonElement element) {
|
public void processText(JsonElement element) {
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package us.myles.ViaVersion.api.type.types;
|
package us.myles.ViaVersion.api.type.types;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import us.myles.ViaVersion.api.Via;
|
||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.util.GsonUtil;
|
import us.myles.ViaVersion.util.GsonUtil;
|
||||||
|
|
||||||
@ -14,7 +16,13 @@ public class ComponentType extends Type<JsonElement> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JsonElement read(ByteBuf buffer) throws Exception {
|
public JsonElement read(ByteBuf buffer) throws Exception {
|
||||||
return GsonUtil.getJsonParser().parse(STRING_TAG.read(buffer));
|
String s = STRING_TAG.read(buffer);
|
||||||
|
try {
|
||||||
|
return GsonUtil.getJsonParser().parse(s);
|
||||||
|
} catch (JsonSyntaxException e) {
|
||||||
|
Via.getPlatform().getLogger().severe("Error when trying to parse json: " + s);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -613,8 +613,9 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Via.getConfig().is1_13TeamColourFix()) {
|
if (Via.getConfig().is1_13TeamColourFix()) {
|
||||||
colour = getLastColor(prefix).ordinal();
|
ChatColor lastColor = getLastColor(prefix);
|
||||||
suffix = getLastColor(prefix).toString() + suffix;
|
colour = lastColor.ordinal();
|
||||||
|
suffix = lastColor.toString() + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapper.write(Type.VAR_INT, colour);
|
wrapper.write(Type.VAR_INT, colour);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren