Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Add optional registry utils to TagUtil (#3819)
Dieser Commit ist enthalten in:
Ursprung
c00bc6b667
Commit
d3af70d76c
@ -26,19 +26,33 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public final class TagUtil {
|
||||
|
||||
public static ListTag<CompoundTag> getRegistryEntries(final CompoundTag tag, final String key) {
|
||||
return getRegistryEntries(tag, key, null);
|
||||
}
|
||||
|
||||
public static ListTag<CompoundTag> getRegistryEntries(final CompoundTag tag, final String key, final @Nullable ListTag<CompoundTag> defaultValue) {
|
||||
CompoundTag registry = tag.getCompoundTag(Key.namespaced(key));
|
||||
if (registry == null) {
|
||||
registry = tag.getCompoundTag(Key.stripMinecraftNamespace(key));
|
||||
if (registry == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
return registry.getListTag("value", CompoundTag.class);
|
||||
}
|
||||
|
||||
public static ListTag<CompoundTag> removeRegistryEntries(final CompoundTag tag, final String key) {
|
||||
return removeRegistryEntries(tag, key, null);
|
||||
}
|
||||
|
||||
public static ListTag<CompoundTag> removeRegistryEntries(final CompoundTag tag, final String key, final @Nullable ListTag<CompoundTag> defaultValue) {
|
||||
String currentKey = Key.namespaced(key);
|
||||
CompoundTag registry = tag.getCompoundTag(currentKey);
|
||||
if (registry == null) {
|
||||
currentKey = Key.stripMinecraftNamespace(key);
|
||||
registry = tag.getCompoundTag(currentKey);
|
||||
if (registry == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
tag.remove(currentKey);
|
||||
return registry.getListTag("value", CompoundTag.class);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren