Class ListTag

java.lang.Object
com.sk89q.jnbt.Tag
com.sk89q.jnbt.ListTag

public final class ListTag extends Tag
The TAG_List tag.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ListTag(Class<? extends Tag> type, List<? extends Tag> value)
    Creates the tag with an empty name.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    asDouble(int index)
    Get a double named with the given index, even if it's another type of number.
    int
    asInt(int index)
    Get an int named with the given index, even if it's another type of number.
    long
    asLong(int index)
    Get a long named with the given index, even if it's another type of number.
    byte
    getByte(int index)
    Get a byte named with the given index.
    byte[]
    getByteArray(int index)
    Get a byte array named with the given index.
    double
    getDouble(int index)
    Get a double named with the given index.
    float
    getFloat(int index)
    Get a float named with the given index.
    getIfExists(int index)
    Get the tag if it exists at the given index.
    int
    getInt(int index)
    Get an int named with the given index.
    int[]
    getIntArray(int index)
    Get a int[] named with the given index.
    getList(int index)
    Get a list of tags named with the given index.
    <T extends Tag>
    List<T>
    getList(int index, Class<T> listType)
    Get a list of tags named with the given index.
    getListTag(int index)
    Get a TagList named with the given index.
    long
    getLong(int index)
    Get a long named with the given index.
    short
    getShort(int index)
    Get a short named with the given index.
    getString(int index)
    Get a string named with the given index.
    Class<? extends Tag>
    Gets the type of item in this list.
    Gets the value of this tag.
    setValue(List<Tag> list)
    Create a new list tag with this tag's name and type.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ListTag

      public ListTag(Class<? extends Tag> type, List<? extends Tag> value)
      Creates the tag with an empty name.
      Parameters:
      type - the type of tag
      value - the value of the tag
  • Method Details

    • getType

      public Class<? extends Tag> getType()
      Gets the type of item in this list.
      Returns:
      The type of item in this list.
    • getValue

      public List<Tag> getValue()
      Description copied from class: Tag
      Gets the value of this tag.
      Specified by:
      getValue in class Tag
      Returns:
      the value
    • setValue

      public ListTag setValue(List<Tag> list)
      Create a new list tag with this tag's name and type.
      Parameters:
      list - the new list
      Returns:
      a new list tag
    • getIfExists

      @Nullable public Tag getIfExists(int index)
      Get the tag if it exists at the given index.
      Parameters:
      index - the index
      Returns:
      the tag or null
    • getByteArray

      public byte[] getByteArray(int index)
      Get a byte array named with the given index.

      If the index does not exist or its value is not a byte array tag, then an empty byte array will be returned.

      Parameters:
      index - the index
      Returns:
      a byte array
    • getByte

      public byte getByte(int index)
      Get a byte named with the given index.

      If the index does not exist or its value is not a byte tag, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a byte
    • getDouble

      public double getDouble(int index)
      Get a double named with the given index.

      If the index does not exist or its value is not a double tag, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a double
    • asDouble

      public double asDouble(int index)
      Get a double named with the given index, even if it's another type of number.

      If the index does not exist or its value is not a number, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a double
    • getFloat

      public float getFloat(int index)
      Get a float named with the given index.

      If the index does not exist or its value is not a float tag, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a float
    • getIntArray

      public int[] getIntArray(int index)
      Get a int[] named with the given index.

      If the index does not exist or its value is not an int array tag, then an empty array will be returned.

      Parameters:
      index - the index
      Returns:
      an int array
    • getInt

      public int getInt(int index)
      Get an int named with the given index.

      If the index does not exist or its value is not an int tag, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      an int
    • asInt

      public int asInt(int index)
      Get an int named with the given index, even if it's another type of number.

      If the index does not exist or its value is not a number, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      an int
    • getList

      public List<Tag> getList(int index)
      Get a list of tags named with the given index.

      If the index does not exist or its value is not a list tag, then an empty list will be returned.

      Parameters:
      index - the index
      Returns:
      a list of tags
    • getListTag

      public ListTag getListTag(int index)
      Get a TagList named with the given index.

      If the index does not exist or its value is not a list tag, then an empty tag list will be returned.

      Parameters:
      index - the index
      Returns:
      a tag list instance
    • getList

      public <T extends Tag> List<T> getList(int index, Class<T> listType)
      Get a list of tags named with the given index.

      If the index does not exist or its value is not a list tag, then an empty list will be returned. If the given index references a list but the list of of a different type, then an empty list will also be returned.

      Type Parameters:
      T - the NBT type
      Parameters:
      index - the index
      listType - the class of the contained type
      Returns:
      a list of tags
    • getLong

      public long getLong(int index)
      Get a long named with the given index.

      If the index does not exist or its value is not a long tag, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a long
    • asLong

      public long asLong(int index)
      Get a long named with the given index, even if it's another type of number.

      If the index does not exist or its value is not a number, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a long
    • getShort

      public short getShort(int index)
      Get a short named with the given index.

      If the index does not exist or its value is not a short tag, then 0 will be returned.

      Parameters:
      index - the index
      Returns:
      a short
    • getString

      public String getString(int index)
      Get a string named with the given index.

      If the index does not exist or its value is not a string tag, then "" will be returned.

      Parameters:
      index - the index
      Returns:
      a string
    • toString

      public String toString()
      Overrides:
      toString in class Object