Beispiel #1
0
 @Override
 public Iterable<DataKey> getSubKeys() {
   final Tag tag = this.findLastTag(this.path, false);
   if (!(tag instanceof CompoundTag)) {
     return (Iterable<DataKey>) Collections.emptyList();
   }
   final List<DataKey> subKeys = (List<DataKey>) Lists.newArrayList();
   for (final String name : ((CompoundTag) tag).getValue().keySet()) {
     subKeys.add(new NBTKey(this.createRelativeKey(name)));
   }
   return subKeys;
 }
Beispiel #2
0
 @Override
 public Map<String, Object> getValuesDeep() {
   final Tag tag = this.findLastTag(this.path, false);
   if (!(tag instanceof CompoundTag)) {
     return Collections.emptyMap();
   }
   final Queue<Node> node =
       new ArrayDeque<Node>(
           (Collection<? extends Node>) ImmutableList.of((Object) new Node(tag)));
   final Map<String, Object> values = (Map<String, Object>) Maps.newHashMap();
   while (!node.isEmpty()) {
     final Node root = node.poll();
     for (final Map.Entry<String, Tag> entry : root.values.entrySet()) {
       final String key = this.createRelativeKey(root.parent, entry.getKey());
       if (entry.getValue() instanceof CompoundTag) {
         node.add(new Node(key, entry.getValue()));
       } else {
         values.put(key, entry.getValue().getValue());
       }
     }
   }
   return values;
 }