Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 16:40:10 +01:00
Use correct deserialization method in SerializerVersion#toComponent (#3795)
MCStructs has multiple methods for parsing jsons depending on the version, we should use them correctly in our wrapper to support all possible cases of components.
Dieser Commit ist enthalten in:
Ursprung
128e191132
Commit
fb434a79bd
@ -93,11 +93,11 @@ public final class ComponentUtil {
|
||||
}
|
||||
|
||||
public static @Nullable JsonElement convertJson(@Nullable final JsonElement element, final SerializerVersion from, final SerializerVersion to) {
|
||||
return element != null ? convert(from, to, from.jsonSerializer.deserialize(element)) : null;
|
||||
return element != null ? convert(from, to, from.toComponent(element)) : null;
|
||||
}
|
||||
|
||||
public static @Nullable JsonElement convertJson(@Nullable final String json, final SerializerVersion from, final SerializerVersion to) {
|
||||
return json != null ? convert(from, to, from.jsonSerializer.deserializeReader(json)) : null;
|
||||
return json != null ? convert(from, to, from.toComponent(json)) : null;
|
||||
}
|
||||
|
||||
private static JsonElement convert(final SerializerVersion from, final SerializerVersion to, final ATextComponent component) {
|
||||
|
@ -77,7 +77,13 @@ public enum SerializerVersion {
|
||||
}
|
||||
|
||||
public ATextComponent toComponent(final String json) {
|
||||
if (ordinal() >= SerializerVersion.V1_20_3.ordinal()) {
|
||||
return jsonSerializer.deserializeParser(json);
|
||||
} else if (ordinal() >= SerializerVersion.V1_9.ordinal()) {
|
||||
return jsonSerializer.deserializeReader(json);
|
||||
} else {
|
||||
return jsonSerializer.deserialize(json);
|
||||
}
|
||||
}
|
||||
|
||||
public ATextComponent toComponent(final Tag tag) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren