Class NBTList

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Object>, Collection<Object>, List<Object>, RandomAccess

public class NBTList extends ArrayList<Object>
Represents an NBT ListTag, which contains one type of NBT Tag.
See Also:
Serialized Form
  • Constructor Details

    • NBTList

      public NBTList(TagType type)
      Create a new NBTList of the given type.
      Parameters:
      type - The type of the NBTList.
  • Method Details

    • getType

      public TagType getType()
      Get the type of this NBTList.
      Returns:
      The type of this NBTList.
    • get

      public Optional<Object> get(int index)
      Get the Object at the given index.
      Specified by:
      get in interface List<Object>
      Overrides:
      get in class ArrayList<Object>
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing an Object at the index.
    • get

      public <T> Optional<T> get(Class<T> type, int index)
      Get the Object of the given type at the given index.
      Type Parameters:
      T - The type of the object to get.
      Parameters:
      type - The type of the object.
      index - The index to get.
      Returns:
      An Optional, containing an Object of type T at the index. Will be empty if the type doesn't match.
    • getByte

      public Optional<Byte> getByte(int index)
      Get the Byte at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the Byte at the index. Will be empty if the type doesn't match.
    • getShort

      public Optional<Short> getShort(int index)
      Get the Short at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the Short at the index. Will be empty if the type doesn't match.
    • getInt

      public Optional<Integer> getInt(int index)
      Get the Integer at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the Integer at the index. Will be empty if the type doesn't match.
    • getLong

      public Optional<Long> getLong(int index)
      Get the Long at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the Long at the index. Will be empty if the type doesn't match.
    • getFloat

      public Optional<Float> getFloat(int index)
      Get the Float at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the Float at the index. Will be empty if the type doesn't match.
    • getDouble

      public Optional<Double> getDouble(int index)
      Get the Double at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the Double at the index. Will be empty if the type doesn't match.
    • getByteArray

      public Optional<byte[]> getByteArray(int index)
      Get the byte[] at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the byte[] at the index. Will be empty if the type doesn't match.
    • getString

      public Optional<String> getString(int index)
      Get the String at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the String at the index. Will be empty if the type doesn't match.
    • getList

      public Optional<NBTList> getList(int index)
      Get the NBTList at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the NBTList at the index. Will be empty if the type doesn't match.
    • getCompound

      public Optional<NBTCompound> getCompound(int index)
      Get the NBTCompound at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the NBTCompound at the index. Will be empty if the type doesn't match.
    • getIntArray

      public Optional<int[]> getIntArray(int index)
      Get the int[] at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the int[] at the index. Will be empty if the type doesn't match.
    • getLongArray

      public Optional<long[]> getLongArray(int index)
      Get the long[] at the given index.
      Parameters:
      index - The index to get.
      Returns:
      An Optional, containing the long[] at the index. Will be empty if the type doesn't match.