Ejemplo n.º 1
0
 private Map<String, Tag> findLastParent(final String[] parts) {
   Map<String, Tag> map = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!map.containsKey(parts[i]) || !(map.get(parts[i]) instanceof CompoundTag)) {
       return null;
     }
     map = map.get(parts[i]).getValue();
   }
   return map;
 }
Ejemplo n.º 2
0
 private void putTag(final String key, final Tag tag) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   Map<String, Tag> parent = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!parent.containsKey(parts[i]) || !(parent.get(parts[i]) instanceof CompoundTag)) {
       parent.put(parts[i], new CompoundTag(parts[i]));
     }
     parent = parent.get(parts[i]).getValue();
   }
   parent.put(tag.getName(), tag);
 }
Ejemplo n.º 3
0
 private Tag findLastTag(final String key, final boolean relative) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.')
                   .omitEmptyStrings()
                   .split((CharSequence) (relative ? this.createRelativeKey(key) : key)),
               (Class) String.class);
   if (parts.length == 0) {
     return new CompoundTag(NBTStorage.this.name, NBTStorage.this.root);
   }
   final Map<String, Tag> map = this.findLastParent(parts);
   if (!map.containsKey(parts[parts.length - 1])) {
     return null;
   }
   return map.get(parts[parts.length - 1]);
 }