3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Fix conversion of mixed json arrays

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-12-09 15:19:05 +01:00
Ursprung 9387b86e4a
Commit cf5f5ed4bb
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F

Datei anzeigen

@ -361,7 +361,7 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
// Use the hash to write a pack uuid // Use the hash to write a pack uuid
final String url = wrapper.read(Type.STRING); final String url = wrapper.read(Type.STRING);
final String hash = wrapper.read(Type.STRING); final String hash = wrapper.read(Type.STRING);
wrapper.write(Type.UUID, UUID.nameUUIDFromBytes(hash.getBytes(StandardCharsets.UTF_8))); wrapper.write(Type.UUID, UUID.nameUUIDFromBytes(url.getBytes(StandardCharsets.UTF_8)));
wrapper.write(Type.STRING, url); wrapper.write(Type.STRING, url);
wrapper.write(Type.STRING, hash); wrapper.write(Type.STRING, hash);
wrapper.passthrough(Type.BOOLEAN); // Required wrapper.passthrough(Type.BOOLEAN); // Required
@ -485,15 +485,20 @@ public final class Protocol1_20_3To1_20_2 extends AbstractProtocol<ClientboundPa
for (final JsonElement entry : element.getAsJsonArray()) { for (final JsonElement entry : element.getAsJsonArray()) {
final Tag convertedTag = convertToTag(entry); final Tag convertedTag = convertToTag(entry);
if (convertedTag instanceof CompoundTag) { if (convertedTag instanceof CompoundTag) {
processedListTag.add(listTag); processedListTag.add(convertedTag);
continue; continue;
} }
// Wrap all entries in compound tags as lists can only consist of one type of tag // Wrap all entries in compound tags, as lists can only consist of one type of tag
final CompoundTag compoundTag = new CompoundTag(); final CompoundTag compoundTag = new CompoundTag();
compoundTag.put("type", new StringTag("text")); compoundTag.put("type", new StringTag("text"));
if (convertedTag instanceof ListTag) {
compoundTag.put("text", new StringTag()); compoundTag.put("text", new StringTag());
compoundTag.put("extra", convertedTag); compoundTag.put("extra", convertedTag);
} else {
compoundTag.put("text", new StringTag(convertedTag.toString()));
}
processedListTag.add(compoundTag);
} }
return processedListTag; return processedListTag;
} }