public final class CompoundTag extends Tag
TAG_Compound
tag.Constructor and Description |
---|
CompoundTag(java.util.Map<java.lang.String,Tag> value)
Creates the tag with an empty name.
|
Modifier and Type | Method and Description |
---|---|
double |
asDouble(java.lang.String key)
Get a double named with the given key, even if it's another
type of number.
|
int |
asInt(java.lang.String key)
Get an int named with the given key, even if it's another
type of number.
|
long |
asLong(java.lang.String key)
Get a long named with the given key, even if it's another
type of number.
|
boolean |
containsKey(java.lang.String key)
Returns whether this compound tag contains the given key.
|
CompoundTagBuilder |
createBuilder()
Create a compound tag builder.
|
byte |
getByte(java.lang.String key)
Get a byte named with the given key.
|
byte[] |
getByteArray(java.lang.String key)
Get a byte array named with the given key.
|
double |
getDouble(java.lang.String key)
Get a double named with the given key.
|
float |
getFloat(java.lang.String key)
Get a float named with the given key.
|
int |
getInt(java.lang.String key)
Get an int named with the given key.
|
int[] |
getIntArray(java.lang.String key)
Get a
int[] named with the given key. |
java.util.List<Tag> |
getList(java.lang.String key)
Get a list of tags named with the given key.
|
<T extends Tag> |
getList(java.lang.String key,
java.lang.Class<T> listType)
Get a list of tags named with the given key.
|
ListTag |
getListTag(java.lang.String key)
Get a
TagList named with the given key. |
long |
getLong(java.lang.String key)
Get a long named with the given key.
|
long[] |
getLongArray(java.lang.String key)
Get a
long[] named with the given key. |
short |
getShort(java.lang.String key)
Get a short named with the given key.
|
java.lang.String |
getString(java.lang.String key)
Get a string named with the given key.
|
java.util.Map<java.lang.String,Tag> |
getValue()
Gets the value of this tag.
|
CompoundTag |
setValue(java.util.Map<java.lang.String,Tag> value)
Return a new compound tag with the given values.
|
java.lang.String |
toString() |
public CompoundTag(java.util.Map<java.lang.String,Tag> value)
value
- the value of the tagpublic boolean containsKey(java.lang.String key)
key
- the given keypublic java.util.Map<java.lang.String,Tag> getValue()
Tag
public CompoundTag setValue(java.util.Map<java.lang.String,Tag> value)
value
- the valuepublic CompoundTagBuilder createBuilder()
public byte[] getByteArray(java.lang.String key)
If the key does not exist or its value is not a byte array tag, then an empty byte array will be returned.
key
- the keypublic byte getByte(java.lang.String key)
If the key does not exist or its value is not a byte tag,
then 0
will be returned.
key
- the keypublic double getDouble(java.lang.String key)
If the key does not exist or its value is not a double tag,
then 0
will be returned.
key
- the keypublic double asDouble(java.lang.String key)
If the key does not exist or its value is not a number,
then 0
will be returned.
key
- the keypublic float getFloat(java.lang.String key)
If the key does not exist or its value is not a float tag,
then 0
will be returned.
key
- the keypublic int[] getIntArray(java.lang.String key)
int[]
named with the given key.
If the key does not exist or its value is not an int array tag, then an empty array will be returned.
key
- the keypublic int getInt(java.lang.String key)
If the key does not exist or its value is not an int tag,
then 0
will be returned.
key
- the keypublic int asInt(java.lang.String key)
If the key does not exist or its value is not a number,
then 0
will be returned.
key
- the keypublic java.util.List<Tag> getList(java.lang.String key)
If the key does not exist or its value is not a list tag, then an empty list will be returned.
key
- the keypublic ListTag getListTag(java.lang.String key)
TagList
named with the given key.
If the key does not exist or its value is not a list tag, then an empty tag list will be returned.
key
- the keypublic <T extends Tag> java.util.List<T> getList(java.lang.String key, java.lang.Class<T> listType)
If the key does not exist or its value is not a list tag, then an empty list will be returned. If the given key references a list but the list of of a different type, then an empty list will also be returned.
T
- the type of listkey
- the keylistType
- the class of the contained typepublic long[] getLongArray(java.lang.String key)
long[]
named with the given key.
If the key does not exist or its value is not an long array tag, then an empty array will be returned.
key
- the keypublic long getLong(java.lang.String key)
If the key does not exist or its value is not a long tag,
then 0
will be returned.
key
- the keypublic long asLong(java.lang.String key)
If the key does not exist or its value is not a number,
then 0
will be returned.
key
- the keypublic short getShort(java.lang.String key)
If the key does not exist or its value is not a short tag,
then 0
will be returned.
key
- the keypublic java.lang.String getString(java.lang.String key)
If the key does not exist or its value is not a string tag,
then ""
will be returned.
key
- the keypublic java.lang.String toString()
toString
in class java.lang.Object