File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
common/src/main/java/com/viaversion/viaversion/util Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 2626public final class TagUtil {
2727
2828 public static ListTag <CompoundTag > getRegistryEntries (final CompoundTag tag , final String key ) {
29+ return getRegistryEntries (tag , key , null );
30+ }
31+
32+ public static ListTag <CompoundTag > getRegistryEntries (final CompoundTag tag , final String key , final @ Nullable ListTag <CompoundTag > defaultValue ) {
2933 CompoundTag registry = tag .getCompoundTag (Key .namespaced (key ));
3034 if (registry == null ) {
3135 registry = tag .getCompoundTag (Key .stripMinecraftNamespace (key ));
36+ if (registry == null ) {
37+ return defaultValue ;
38+ }
3239 }
3340 return registry .getListTag ("value" , CompoundTag .class );
3441 }
3542
3643 public static ListTag <CompoundTag > removeRegistryEntries (final CompoundTag tag , final String key ) {
44+ return removeRegistryEntries (tag , key , null );
45+ }
46+
47+ public static ListTag <CompoundTag > removeRegistryEntries (final CompoundTag tag , final String key , final @ Nullable ListTag <CompoundTag > defaultValue ) {
3748 String currentKey = Key .namespaced (key );
3849 CompoundTag registry = tag .getCompoundTag (currentKey );
3950 if (registry == null ) {
4051 currentKey = Key .stripMinecraftNamespace (key );
4152 registry = tag .getCompoundTag (currentKey );
53+ if (registry == null ) {
54+ return defaultValue ;
55+ }
4256 }
4357 tag .remove (currentKey );
4458 return registry .getListTag ("value" , CompoundTag .class );
You can’t perform that action at this time.
0 commit comments