3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-07-01 21:18:02 +02:00

Check both namespaced and implicit key when replacing registry

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-05-01 10:28:53 +02:00
Ursprung fa3c933b2f
Commit c00bc6b667
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
2 geänderte Dateien mit 16 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -190,7 +190,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
chatTypeStorage.clear();
final CompoundTag registry = wrapper.passthrough(Type.NAMED_COMPOUND_TAG);
final ListTag<CompoundTag> chatTypes = TagUtil.getRegistryEntries(registry, "chat_type");
final ListTag<CompoundTag> chatTypes = TagUtil.removeRegistryEntries(registry, "chat_type");
for (final CompoundTag chatType : chatTypes) {
final NumberTag idTag = chatType.getNumberTag("id");
chatTypeStorage.addChatType(idTag.asInt(), chatType);

Datei anzeigen

@ -33,6 +33,21 @@ public final class TagUtil {
return registry.getListTag("value", CompoundTag.class);
}
public static ListTag<CompoundTag> removeRegistryEntries(final CompoundTag tag, final String key) {
String currentKey = Key.namespaced(key);
CompoundTag registry = tag.getCompoundTag(currentKey);
if (registry == null) {
currentKey = Key.stripMinecraftNamespace(key);
registry = tag.getCompoundTag(currentKey);
}
tag.remove(currentKey);
return registry.getListTag("value", CompoundTag.class);
}
public static boolean removeNamespaced(final CompoundTag tag, final String key) {
return tag.remove(Key.namespaced(key)) != null || tag.remove(Key.stripMinecraftNamespace(key)) != null;
}
public static Tag handleDeep(final Tag tag, final TagUpdater consumer) {
return handleDeep(null, tag, consumer);
}