Class ListTag<T extends Tag>
java.lang.Object
com.viaversion.nbt.tag.ListTag<T>
- Direct Known Subclasses:
MixedListTag
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a tag to this list tag.Returns the raw string representation of the value of this tag.copy()Returns a copy of this tag.booleanget(int index) Gets the tag at the given index of this list tag.Gets the element type of the ListTag.intgetTagId()Returns the NBT tag id of this tag type, used in I/O.getValue()Returns the value of this tag.inthashCode()booleanisEmpty()iterator()static ListTag<?> Creates a list tag, possibly of mixed types.static ListTag<?> read(DataInput in, TagLimiter tagLimiter, int nestingLevel) remove(int index) Removes the tag at the given index of this list tag.booleanRemoves a tag from this list tag.Sets the tag at the given index of this list tag.voidSets the value of this tag.intsize()Gets the number of tags in this list tag.stream()toString()voidwrite(DataOutput out) Writes this tag to an output stream.Methods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
ID
public static final int ID- See Also:
-
-
Constructor Details
-
ListTag
Deprecated.useMixedListTagif you need to mix element typesCreates an empty list tag and no defined type. -
ListTag
-
ListTag
Creates a list tag and value. The list tag's type will be set to that of the first tag being added, or null if the given list is empty.- Parameters:
value- The value of the tag.- Throws:
IllegalArgumentException- If all tags in the list are not of the same type.
-
-
Method Details
-
of
-
read
public static ListTag<?> read(DataInput in, TagLimiter tagLimiter, int nestingLevel) throws IOException - Throws:
IOException
-
getValue
-
asRawString
Description copied from interface:TagReturns the raw string representation of the value of this tag. For SNBT, useSNBT.serialize(Tag).- Specified by:
asRawStringin interfaceTag- Returns:
- raw string representation of the value of this tag
-
setValue
Sets the value of this tag. The list tag's type will be set to that of the first tag being added, or null if the given list is empty.- Parameters:
value- New value of this tag.- Throws:
IllegalArgumentException- If all tags in the list are not of the same type.
-
getElementType
-
add
Adds a tag to this list tag. If the list does not yet have a type, it will be set to the type of the tag being added.- Parameters:
tag- Tag to add. Should not be null.- Returns:
- If the list was changed as a result.
- Throws:
IllegalArgumentException- If the tag's type differs from the list tag's type.
-
remove
Removes a tag from this list tag.- Parameters:
tag- Tag to remove.- Returns:
- If the list contained the tag.
-
get
Gets the tag at the given index of this list tag.- Parameters:
index- Index of the tag.- Returns:
- The tag at the given index.
-
set
-
remove
Removes the tag at the given index of this list tag.- Parameters:
index- Index of the tag.- Returns:
- The removed tag at the given index.
-
size
public int size()Gets the number of tags in this list tag.- Returns:
- The size of this list tag.
-
isEmpty
public boolean isEmpty() -
stream
-
iterator
-
write
Description copied from interface:TagWrites this tag to an output stream.- Specified by:
writein interfaceTag- Parameters:
out- data output to write to- Throws:
IOException- if an I/O error occurs
-
copy
-
equals
-
hashCode
-
getTagId
-
toString
-
MixedListTagif you need to mix element types