public class CompoundTag extends Tag<Map<String,Tag>> implements DynamicallyTypedMapWithDoubles<String>
TAG_Compound
tag.Constructor and Description |
---|
CompoundTag()
Creates a new, empty CompoundTag.
|
CompoundTag(Map<String,Tag> value) |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(@NonNls String key)
Check if the compound contains the given key.
|
boolean |
getBoolean(@NonNls String key)
Retrieves an entry as a
boolean . |
boolean |
getBoolean(@NonNls String key,
boolean defaultValue)
Returns the boolean value of a
byte subtag if present, or a default otherwise. |
byte |
getByte(@NonNls String key)
Returns the value of a
byte subtag. |
byte[] |
getByteArray(@NonNls String key)
Returns the value of a
byte[] subtag. |
CompoundTag |
getCompound(@NonNls String key)
Returns the value of a compound subtag.
|
List<CompoundTag> |
getCompoundList(@NonNls String key)
Returns the value of a list subtag with CompoundTag elements.
|
double |
getDouble(@NonNls String key)
Returns the value of a
double subtag. |
float |
getFloat(@NonNls String key)
Returns the value of a
float subtag. |
int |
getInt(@NonNls String key)
Returns the value of an
int subtag. |
int[] |
getIntArray(@NonNls String key)
Returns the value of an
int[] subtag. |
<V> List<V> |
getList(@NonNls String key,
TagType type)
Returns the value of a
List subtag. |
long |
getLong(@NonNls String key)
Returns the value of a
long subtag. |
Number |
getNumber(String key)
Returns the value of a numeric subtag.
|
short |
getShort(@NonNls String key)
Returns the value of a
short subtag. |
String |
getString(@NonNls String key)
Returns the value of a
String subtag. |
Map<String,Tag> |
getValue()
The value.
|
boolean |
isByte(@NonNls String key)
Test whether the subtag with the given key is of
byte type. |
boolean |
isByteArray(@NonNls String key)
Test whether the subtag with the given key is of
byte[] type. |
boolean |
isCompound(@NonNls String key)
Test whether the subtag with the given key is of
CompoundTag type. |
boolean |
isCompoundList(@NonNls String key)
Test whether the subtag with the given key is of
List type with elements of type
CompoundTag . |
boolean |
isDouble(@NonNls String key)
Test whether the subtag with the given key is of
double type. |
boolean |
isEmpty() |
boolean |
isFloat(@NonNls String key)
Test whether the subtag with the given key is of
float type. |
boolean |
isInt(@NonNls String key)
Test whether the subtag with the given key is of
int type. |
boolean |
isIntArray(@NonNls String key)
Test whether the subtag with the given key is of
int[] type. |
boolean |
isList(@NonNls String key,
TagType type)
Test whether the subtag with the given key is of
List type. |
boolean |
isLong(@NonNls String key)
Test whether the subtag with the given key is of
long type. |
boolean |
isNumeric(@NonNls String key)
Test whether the subtag with the given key is of a numeric type.
|
boolean |
isShort(@NonNls String key)
Test whether the subtag with the given key is of
short type. |
boolean |
isString(@NonNls String key)
Test whether the subtag with the given key is of
String type. |
boolean |
iterateCompoundList(@NonNls String key,
Consumer<? super CompoundTag> consumer)
Applies the given function to each compound tag in a compound-list subtag, if that subtag
exists.
|
boolean |
matches(CompoundTag other)
Checks to see if this tag is a strict, deep submap of the given CompoundTag.
|
void |
mergeInto(CompoundTag other,
boolean overwrite)
Merges the contents of this compound into the supplied compound.
|
void |
putBool(@NonNls String key,
boolean value) |
void |
putByte(@NonNls String key,
int value) |
void |
putByteArray(@NonNls String key,
byte... value) |
void |
putCompound(@NonNls String key,
CompoundTag tag) |
void |
putCompoundList(@NonNls String key,
List<CompoundTag> list)
Adds or replaces a list subtag with a list of compound tags.
|
void |
putDouble(@NonNls String key,
double value) |
void |
putDoubleList(@NonNls String key,
List<Double> list)
Adds or replaces a list subtag with a list of doubles.
|
void |
putFloat(@NonNls String key,
double value) |
void |
putFloatList(@NonNls String key,
List<Float> list)
Adds or replaces a list subtag with a list of floats.
|
void |
putInt(@NonNls String key,
int value) |
void |
putIntArray(@NonNls String key,
int... value) |
<V> void |
putList(@NonNls String key,
TagType type,
List<V> value,
Function<? super V,? extends Tag> tagCreator)
Adds or replaces a list subtag, converting the list entries to tags.
|
void |
putLong(@NonNls String key,
long value) |
void |
putLongList(@NonNls String key,
List<Long> list)
Adds or replaces a list subtag with a list of longs.
|
void |
putShort(@NonNls String key,
int value) |
void |
putString(@NonNls String key,
@NonNls String value) |
void |
putStringList(@NonNls String key,
List<String> list)
Adds or replaces a list subtag with a list of strings.
|
boolean |
readBoolean(@NonNls String key,
Consumer<? super Boolean> consumer)
Applies the given function to a byte subtag if it is present, converting it to boolean first.
|
boolean |
readBooleanNegated(@NonNls String key,
Consumer<? super Boolean> consumer)
Applies the given function to a byte subtag if it is present, converting it to boolean and
negating it first.
|
boolean |
readByte(@NonNls String key,
Consumer<? super Byte> consumer)
Applies the given function to a byte subtag if it is present.
|
boolean |
readByteArray(@NonNls String key,
Consumer<? super byte[]> consumer)
Applies the given function to a byte array subtag if it is present.
|
boolean |
readCompound(@NonNls String key,
Consumer<? super CompoundTag> consumer)
Applies the given function to a compound subtag if it is present.
|
boolean |
readCompoundList(@NonNls String key,
Consumer<? super List<CompoundTag>> consumer)
Applies the given function to a list subtag if it is present and its contents are compound
tags.
|
boolean |
readDouble(@NonNls String key,
DoubleConsumer consumer)
Applies the given function to a double subtag if it is present.
|
boolean |
readDoubleList(@NonNls String key,
Consumer<? super List<Double>> consumer)
Applies the given function to a list subtag if it is present and its contents are double
tags.
|
boolean |
readFloat(@NonNls String key,
FloatConsumer consumer)
Applies the given function to a float subtag if it is present.
|
boolean |
readFloatList(@NonNls String key,
Consumer<? super List<Float>> consumer)
Applies the given function to a list subtag if it is present and its contents are float
tags.
|
boolean |
readInt(@NonNls String key,
IntConsumer consumer)
Applies the given function to an integer subtag if it is present.
|
boolean |
readIntArray(@NonNls String key,
Consumer<? super int[]> consumer)
Applies the given function to an integer array subtag if it is present.
|
boolean |
readItem(@NonNls String key,
Consumer<? super org.bukkit.inventory.ItemStack> consumer)
Applies the given function to a compound subtag if it is present, first converting it to an
item using
NbtSerialization.readItem(CompoundTag) . |
<T> boolean |
readList(@NonNls String key,
TagType type,
Consumer<? super List<T>> consumer)
Applies the given function to a list subtag if it is present, converting it to a list of
values first.
|
boolean |
readLong(@NonNls String key,
LongConsumer consumer)
Applies the given function to a long subtag if it is present.
|
boolean |
readShort(@NonNls String key,
ShortConsumer consumer)
Applies the given function to an integer subtag if it is present.
|
boolean |
readString(@NonNls String key,
Consumer<? super String> consumer)
Applies the given function to a string subtag if it is present.
|
boolean |
readStringList(@NonNls String key,
Consumer<? super List<String>> consumer)
Applies the given function to a list subtag if it is present and its contents are string
tags.
|
boolean |
readUuid(@NonNls String keyMost,
@NonNls String keyLeast,
Consumer<? super UUID> consumer)
Applies the given function to a UUID extracted from the given pair of long subtags, if they
both exist.
|
void |
remove(@NonNls String key) |
Optional<CompoundTag> |
tryGetCompound(@NonNls String key)
Returns the value of a compound subtag, if it exists.
|
Optional<Integer> |
tryGetInt(@NonNls String key)
Returns the value of an int subtag if it is present.
|
Optional<Long> |
tryGetLong(@NonNls String key)
Returns the value of a long subtag if it is present.
|
Optional<org.bukkit.Material> |
tryGetMaterial(@NonNls String key)
Reads a material from a string ID or numeric ID, depending on the tag type.
|
Optional<String> |
tryGetString(@NonNls String key)
Returns the value of a string subtag if it is present.
|
Optional<UUID> |
tryGetUuid(@NonNls String keyMost,
@NonNls String keyLeast)
Returns a UUID extracted from the given pair of long subtags, if they both exist.
|
protected void |
valueToString(StringBuilder builder) |
protected void valueToString(StringBuilder builder)
valueToString
in class Tag<Map<String,Tag>>
public boolean isEmpty()
public boolean containsKey(@NonNls @NonNls String key)
key
- The key.public void remove(@NonNls @NonNls String key)
public boolean matches(CompoundTag other)
other
- The CompoundTag that should contain our values.public void mergeInto(CompoundTag other, boolean overwrite)
other
- the other compound to merge into.overwrite
- whether keys already set in the other compound should be
overwritten.public Number getNumber(String key)
key
- the key to look uppublic byte getByte(@NonNls @NonNls String key)
byte
subtag.key
- the key to look uppublic short getShort(@NonNls @NonNls String key)
short
subtag.key
- the key to look uppublic int getInt(@NonNls @NonNls String key)
int
subtag.getInt
in interface DynamicallyTypedMap<String>
key
- the key to look uppublic boolean getBoolean(@NonNls @NonNls String key)
DynamicallyTypedMap
boolean
.getBoolean
in interface DynamicallyTypedMap<String>
key
- the key to look uppublic boolean getBoolean(@NonNls @NonNls String key, boolean defaultValue)
byte
subtag if present, or a default otherwise.key
- the key to look updefaultValue
- the value to return if the subtag is missingpublic long getLong(@NonNls @NonNls String key)
long
subtag.key
- the key to look uppublic float getFloat(@NonNls @NonNls String key)
float
subtag.getFloat
in interface DynamicallyTypedMapWithFloats<String>
key
- the key to look uppublic double getDouble(@NonNls @NonNls String key)
double
subtag.getDouble
in interface DynamicallyTypedMapWithDoubles<String>
key
- the key to look uppublic byte[] getByteArray(@NonNls @NonNls String key)
byte[]
subtag.key
- the key to look uppublic String getString(@NonNls @NonNls String key)
String
subtag.getString
in interface DynamicallyTypedMap<String>
key
- the key to look uppublic int[] getIntArray(@NonNls @NonNls String key)
int[]
subtag.key
- the key to look uppublic <V> List<V> getList(@NonNls @NonNls String key, TagType type)
List
subtag.V
- the list element typekey
- the key to look uptype
- the list element tag typepublic CompoundTag getCompound(@NonNls @NonNls String key)
key
- the key to look uppublic Optional<CompoundTag> tryGetCompound(@NonNls @NonNls String key)
tryGetCompound("foo", "bar")
returns a compound subtag
called "bar" of a compound subtag called "foo", or null if either of those tags doesn't exist
or isn't compound.key
- the key to look uppublic boolean readCompound(@NonNls @NonNls String key, Consumer<? super CompoundTag> consumer)
tryGetCompound(String)
.key
- the key to look upconsumer
- the function to applypublic boolean readFloat(@NonNls @NonNls String key, FloatConsumer consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readDouble(@NonNls @NonNls String key, DoubleConsumer consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readInt(@NonNls @NonNls String key, IntConsumer consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readByteArray(@NonNls @NonNls String key, Consumer<? super byte[]> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readIntArray(@NonNls @NonNls String key, Consumer<? super int[]> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readLong(@NonNls @NonNls String key, LongConsumer consumer)
key
- the key to look upconsumer
- the function to applypublic Optional<Long> tryGetLong(@NonNls @NonNls String key)
key
- the key to look uppublic boolean readShort(@NonNls @NonNls String key, ShortConsumer consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readItem(@NonNls @NonNls String key, Consumer<? super org.bukkit.inventory.ItemStack> consumer)
NbtSerialization.readItem(CompoundTag)
.key
- the key to look upconsumer
- the function to applypublic boolean readBoolean(@NonNls @NonNls String key, Consumer<? super Boolean> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readByte(@NonNls @NonNls String key, Consumer<? super Byte> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readBooleanNegated(@NonNls @NonNls String key, Consumer<? super Boolean> consumer)
key
- the key to look upconsumer
- the function to applypublic <T> boolean readList(@NonNls @NonNls String key, TagType type, Consumer<? super List<T>> consumer)
T
- the type to convert the list entries tokey
- the key to look uptype
- the type that the list entries must beconsumer
- the function to applypublic boolean readCompoundList(@NonNls @NonNls String key, Consumer<? super List<CompoundTag>> consumer)
iterateCompoundList(String, Consumer)
.key
- the key to look upconsumer
- the function to applypublic boolean iterateCompoundList(@NonNls @NonNls String key, Consumer<? super CompoundTag> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readStringList(@NonNls @NonNls String key, Consumer<? super List<String>> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readFloatList(@NonNls @NonNls String key, Consumer<? super List<Float>> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readDoubleList(@NonNls @NonNls String key, Consumer<? super List<Double>> consumer)
key
- the key to look upconsumer
- the function to applypublic boolean readString(@NonNls @NonNls String key, Consumer<? super String> consumer)
key
- the key to look upconsumer
- the function to applypublic Optional<org.bukkit.Material> tryGetMaterial(@NonNls @NonNls String key)
key
- the key to look uppublic Optional<String> tryGetString(@NonNls @NonNls String key)
key
- the key to look uppublic Optional<Integer> tryGetInt(@NonNls @NonNls String key)
key
- the key to look uppublic boolean readUuid(@NonNls @NonNls String keyMost, @NonNls @NonNls String keyLeast, Consumer<? super UUID> consumer)
keyMost
- the key to look up the high word of the UUIDkeyLeast
- the key to look up the low word of the UUIDconsumer
- the function to applypublic Optional<UUID> tryGetUuid(@NonNls @NonNls String keyMost, @NonNls @NonNls String keyLeast)
keyMost
- the key to look up the high word of the UUIDkeyLeast
- the key to look up the low word of the UUIDpublic List<CompoundTag> getCompoundList(@NonNls @NonNls String key)
key
- the key to look uppublic boolean isNumeric(@NonNls @NonNls String key)
key
- the key to look uppublic boolean isByte(@NonNls @NonNls String key)
byte
type.key
- the key to look upbyte
; false otherwisepublic boolean isShort(@NonNls @NonNls String key)
short
type.key
- the key to look upshort
; false otherwisepublic boolean isInt(@NonNls @NonNls String key)
int
type.key
- the key to look upint
; false otherwisepublic boolean isLong(@NonNls @NonNls String key)
long
type.key
- the key to look uplong
; false otherwisepublic boolean isFloat(@NonNls @NonNls String key)
float
type.key
- the key to look upfloat
; false otherwisepublic boolean isDouble(@NonNls @NonNls String key)
double
type.key
- the key to look updouble
; false otherwisepublic boolean isByteArray(@NonNls @NonNls String key)
byte[]
type.key
- the key to look upbyte[]
; false otherwisepublic boolean isString(@NonNls @NonNls String key)
String
type.key
- the key to look upString
; false otherwisepublic boolean isIntArray(@NonNls @NonNls String key)
int[]
type.key
- the key to look upint[]
; false otherwisepublic boolean isList(@NonNls @NonNls String key, TagType type)
List
type.public boolean isCompound(@NonNls @NonNls String key)
CompoundTag
type.key
- the key to look upCompoundTag
; false otherwisepublic boolean isCompoundList(@NonNls @NonNls String key)
List
type with elements of type
CompoundTag
.key
- the key to look upList
with elements of type
CompoundTag
; false otherwisepublic void putBool(@NonNls @NonNls String key, boolean value)
public void putByte(@NonNls @NonNls String key, int value)
public void putShort(@NonNls @NonNls String key, int value)
public void putInt(@NonNls @NonNls String key, int value)
public void putLong(@NonNls @NonNls String key, long value)
public void putFloat(@NonNls @NonNls String key, double value)
public void putDouble(@NonNls @NonNls String key, double value)
public void putByteArray(@NonNls @NonNls String key, byte... value)
public void putIntArray(@NonNls @NonNls String key, int... value)
public <V> void putList(@NonNls @NonNls String key, TagType type, List<V> value, Function<? super V,? extends Tag> tagCreator)
V
- the list elements' Java typekey
- the key to write totype
- the list elements' tag typevalue
- the list contents, as objects to convert to tagstagCreator
- a function that will convert each V to an element tagpublic void putCompound(@NonNls @NonNls String key, CompoundTag tag)
public void putCompoundList(@NonNls @NonNls String key, List<CompoundTag> list)
key
- the key to write tolist
- the list contents as compound tagspublic void putStringList(@NonNls @NonNls String key, List<String> list)
key
- the key to write tolist
- the list contents as strings, to convert to string tagspublic void putFloatList(@NonNls @NonNls String key, List<Float> list)
key
- the key to write tolist
- the list contents as floats, to convert to float tagspublic void putDoubleList(@NonNls @NonNls String key, List<Double> list)
key
- the key to write tolist
- the list contents as doubles, to convert to double tagspublic void putLongList(@NonNls @NonNls String key, List<Long> list)
key
- the key to write tolist
- the list contents as longs, to convert to long tagsCopyright © 2021. All rights reserved.