public abstract class CompoundTag extends Tag
TAG_Compound
tag.Constructor and Description |
---|
CompoundTag(Map<String,Tag> value)
Creates the tag with an empty name.
|
Modifier and Type | Method and Description |
---|---|
double |
asDouble(String key)
Get a double named with the given key, even if it's another
type of number.
|
int |
asInt(String key)
Get an int named with the given key, even if it's another
type of number.
|
long |
asLong(String key)
Get a long named with the given key, even if it's another
type of number.
|
boolean |
containsKey(String key)
Returns whether this compound tag contains the given key.
|
CompoundTagBuilder |
createBuilder()
Create a compound tag builder.
|
boolean |
getBoolean(String key) |
byte |
getByte(String key)
Get a byte named with the given key.
|
byte[] |
getByteArray(String key)
Get a byte array named with the given key.
|
CompoundTag |
getCompound(String key) |
double |
getDouble(String key)
Get a double named with the given key.
|
float |
getFloat(String key)
Get a float named with the given key.
|
int |
getInt(String key)
Get an int named with the given key.
|
int[] |
getIntArray(String key)
Get a
int[] named with the given key. |
List<Tag> |
getList(String key)
Get a list of tags named with the given key.
|
<T extends Tag> |
getList(String key,
Class<T> listType)
Get a list of tags named with the given key.
|
ListTag |
getListTag(String key)
Get a
TagList named with the given key. |
long |
getLong(String key)
Get a long named with the given key.
|
short |
getShort(String key)
Get a short named with the given key.
|
String |
getString(String key)
Get a string named with the given key.
|
Map<String,Tag> |
getValue()
Gets the value of this tag.
|
CompoundTag |
setValue(Map<String,Tag> value)
Return a new compound tag with the given values.
|
String |
toString() |
public boolean containsKey(String key)
key
- the given keypublic Map<String,Tag> getValue()
Tag
public CompoundTag setValue(Map<String,Tag> value)
value
- the valuepublic CompoundTagBuilder createBuilder()
public byte[] getByteArray(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(String key)
If the key does not exist or its value is not a byte tag,
then 0
will be returned.
key
- the keypublic boolean getBoolean(String key)
public CompoundTag getCompound(String key)
public double getDouble(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(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(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(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(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(String key)
If the key does not exist or its value is not a number,
then 0
will be returned.
key
- the keypublic List<Tag> getList(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(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> List<T> getList(String key, 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 getLong(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(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(String key)
If the key does not exist or its value is not a short tag,
then 0
will be returned.
key
- the keypublic String getString(String key)
If the key does not exist or its value is not a string tag,
then ""
will be returned.
key
- the keyCopyright © 2020. All rights reserved.