Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +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.JsonObject;
|
||||
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.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
@ -99,9 +101,14 @@ public class ComponentRewriter {
|
||||
}
|
||||
|
||||
public JsonElement processText(String value) {
|
||||
JsonElement root = GsonUtil.getJsonParser().parse(value);
|
||||
processText(root);
|
||||
return root;
|
||||
try {
|
||||
JsonElement root = GsonUtil.getJsonParser().parse(value);
|
||||
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) {
|
||||
|
@ -1,7 +1,9 @@
|
||||
package us.myles.ViaVersion.api.type.types;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.util.GsonUtil;
|
||||
|
||||
@ -14,7 +16,13 @@ public class ComponentType extends Type<JsonElement> {
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@ -613,8 +613,9 @@ public class Protocol1_13To1_12_2 extends Protocol<ClientboundPackets1_12_1, Cli
|
||||
}
|
||||
|
||||
if (Via.getConfig().is1_13TeamColourFix()) {
|
||||
colour = getLastColor(prefix).ordinal();
|
||||
suffix = getLastColor(prefix).toString() + suffix;
|
||||
ChatColor lastColor = getLastColor(prefix);
|
||||
colour = lastColor.ordinal();
|
||||
suffix = lastColor.toString() + suffix;
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, colour);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren