Class CompoundTag

java.lang.Object
org.moddingx.launcherlib.nbt.tag.CompoundTag
All Implemented Interfaces:
Iterable<Map.Entry<String,Tag>>, Tag

public final class CompoundTag extends Object implements Tag, Iterable<Map.Entry<String,Tag>>
Compound tag (TagType.COMPOUND).
  • Constructor Details

    • CompoundTag

      public CompoundTag()
      Creates an empty compound tag.
    • CompoundTag

      public CompoundTag(Map<String,Tag> elements)
      Creates a new compound tag with the given contents.
  • Method Details

    • type

      public TagType type()
      Description copied from interface: Tag
      Gets the TagType for this tag.
      Specified by:
      type in interface Tag
    • copy

      public CompoundTag copy()
      Description copied from interface: Tag
      Makes a copy of this tag. For immutable tags, this may return the same object.
      Specified by:
      copy in interface Tag
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • size

      public int size()
      Gets the size of this tag.
    • has

      public boolean has(String key)
      Gets whether this tag contains a value assigned to the given key.
    • has

      public boolean has(String key, TagType type)
      Gets whether this tag contains a value assigned to the given key that is of type type.
    • get

      public Tag get(String key)
      Gets a value from this tag.
      Throws:
      NoSuchElementException - if the given key does not exist.
    • put

      public Tag put(String key, Tag value)
      Puts a new value into this tag.
      Returns:
      The old value for that key or null if there was none before.
    • put

      public Tag put(Map.Entry<String,Tag> entry)
      Puts a new value into this tag.
      Returns:
      The old value for that key or null if there was none before.
    • putAll

      public void putAll(CompoundTag tag)
      Puts multiple values into this tag.
    • putAll

      public void putAll(Map<String,Tag> values)
      Puts multiple values into this tag.
    • merge

      public void merge(CompoundTag tag)
      Puts all values from the given CompoundTag into this CompoundTag, recursively merging entries, where both tags contain a CompoundTag.
    • remove

      public Tag remove(String key)
      Removes the value assigned to the given key.
      Returns:
      The value that was removed.
    • clear

      public void clear()
      Removes all elements from this tag.
    • keys

      public Set<String> keys()
      Gets a set of all keys in this tag.
    • getByte

      public byte getByte(String key)
    • getShort

      public short getShort(String key)
    • getInt

      public int getInt(String key)
    • getLong

      public long getLong(String key)
    • getFloat

      public float getFloat(String key)
    • getDouble

      public double getDouble(String key)
    • getString

      public String getString(String key)
    • getList

      public ListTag getList(String key)
    • getCompound

      public CompoundTag getCompound(String key)
    • putByte

      public void putByte(String key, byte value)
    • putShort

      public void putShort(String key, short value)
    • putInt

      public void putInt(String key, int value)
    • putLong

      public void putLong(String key, long value)
    • putFloat

      public void putFloat(String key, float value)
    • putDouble

      public void putDouble(String key, double value)
    • putString

      public void putString(String key, String value)
    • iterator

      @Nonnull public Iterator<Map.Entry<String,Tag>> iterator()
      Specified by:
      iterator in interface Iterable<Map.Entry<String,Tag>>
    • stream

      @Nonnull public Stream<Map.Entry<String,Tag>> stream()