Package net.kyori.adventure.nbt
Interface CompoundBinaryTag
-
- All Superinterfaces:
BinaryTag
,BinaryTagLike
,CompoundTagSetter<CompoundBinaryTag>
,net.kyori.examination.Examinable
,java.lang.Iterable<java.util.Map.Entry<java.lang.String,? extends BinaryTag>>
public interface CompoundBinaryTag extends BinaryTag, CompoundTagSetter<CompoundBinaryTag>, java.lang.Iterable<java.util.Map.Entry<java.lang.String,? extends BinaryTag>>
Binary tag holding a mapping of string keys toBinaryTag
values.- Since:
- 4.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
CompoundBinaryTag.Builder
A compound tag builder.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static @NotNull CompoundBinaryTag.Builder
builder()
Creates a builder.static @NotNull CompoundBinaryTag
empty()
Gets an empty compound tag.static @NotNull CompoundBinaryTag
from(@NotNull java.util.Map<java.lang.String,? extends BinaryTag> tags)
Creates a compound tag populated withtags
.@Nullable BinaryTag
get(java.lang.String key)
Gets a tag.default boolean
getBoolean(@NotNull java.lang.String key)
Gets a boolean.default boolean
getBoolean(@NotNull java.lang.String key, boolean defaultValue)
Gets a boolean.default byte
getByte(@NotNull java.lang.String key)
Gets a byte.byte
getByte(@NotNull java.lang.String key, byte defaultValue)
Gets a byte.byte @NotNull []
getByteArray(@NotNull java.lang.String key)
Gets an array of bytes.byte @NotNull []
getByteArray(@NotNull java.lang.String key, byte @NotNull [] defaultValue)
Gets an array of bytes.default @NotNull CompoundBinaryTag
getCompound(@NotNull java.lang.String key)
Gets a compound.@NotNull CompoundBinaryTag
getCompound(@NotNull java.lang.String key, @NotNull CompoundBinaryTag defaultValue)
Gets a compound.default double
getDouble(@NotNull java.lang.String key)
Gets a double.double
getDouble(@NotNull java.lang.String key, double defaultValue)
Gets a double.default float
getFloat(@NotNull java.lang.String key)
Gets a float.float
getFloat(@NotNull java.lang.String key, float defaultValue)
Gets a float.default int
getInt(@NotNull java.lang.String key)
Gets an int.int
getInt(@NotNull java.lang.String key, int defaultValue)
Gets an int.int @NotNull []
getIntArray(@NotNull java.lang.String key)
Gets an array of ints.int @NotNull []
getIntArray(@NotNull java.lang.String key, int @NotNull [] defaultValue)
Gets an array of ints.default @NotNull ListBinaryTag
getList(@NotNull java.lang.String key)
Gets a list.default @NotNull ListBinaryTag
getList(@NotNull java.lang.String key, @NotNull BinaryTagType<? extends BinaryTag> expectedType)
Gets a list, ensuring that the type is the same astype
.@NotNull ListBinaryTag
getList(@NotNull java.lang.String key, @NotNull BinaryTagType<? extends BinaryTag> expectedType, @NotNull ListBinaryTag defaultValue)
Gets a list, ensuring that the type is the same astype
.@NotNull ListBinaryTag
getList(@NotNull java.lang.String key, @NotNull ListBinaryTag defaultValue)
Gets a list.default long
getLong(@NotNull java.lang.String key)
Gets a long.long
getLong(@NotNull java.lang.String key, long defaultValue)
Gets a long.long @NotNull []
getLongArray(@NotNull java.lang.String key)
Gets an array of longs.long @NotNull []
getLongArray(@NotNull java.lang.String key, long @NotNull [] defaultValue)
Gets an array of longs.default short
getShort(@NotNull java.lang.String key)
Gets a short.short
getShort(@NotNull java.lang.String key, short defaultValue)
Gets a short.default @NotNull java.lang.String
getString(@NotNull java.lang.String key)
Gets a string.@NotNull java.lang.String
getString(@NotNull java.lang.String key, @NotNull java.lang.String defaultValue)
Gets a string.@NotNull java.util.Set<java.lang.String>
keySet()
Gets a set of all keys.int
size()
Gets the number of elements in the compound.default @NotNull BinaryTagType<CompoundBinaryTag>
type()
Gets the tag type.-
Methods inherited from interface net.kyori.adventure.nbt.BinaryTag
asBinaryTag
-
Methods inherited from interface net.kyori.adventure.nbt.CompoundTagSetter
put, put, put, putBoolean, putByte, putByteArray, putDouble, putFloat, putInt, putIntArray, putLong, putLongArray, putShort, putString, remove, remove
-
-
-
-
Method Detail
-
empty
@NotNull static @NotNull CompoundBinaryTag empty()
Gets an empty compound tag.- Returns:
- an empty tag
- Since:
- 4.0.0
-
from
@NotNull static @NotNull CompoundBinaryTag from(@NotNull @NotNull java.util.Map<java.lang.String,? extends BinaryTag> tags)
Creates a compound tag populated withtags
.If
tags
is empty,empty()
will be returned.- Parameters:
tags
- the map of contents for the created tag- Returns:
- a compound tag
- Since:
- 4.4.0
-
builder
@NotNull static @NotNull CompoundBinaryTag.Builder builder()
Creates a builder.- Returns:
- a new builder
- Since:
- 4.0.0
-
type
@NotNull default @NotNull BinaryTagType<CompoundBinaryTag> type()
Description copied from interface:BinaryTag
Gets the tag type.
-
keySet
@NotNull @NotNull java.util.Set<java.lang.String> keySet()
Gets a set of all keys.- Returns:
- the keys
- Since:
- 4.0.0
-
get
@Nullable @Nullable BinaryTag get(java.lang.String key)
Gets a tag.- Parameters:
key
- the key- Returns:
- a tag
- Since:
- 4.0.0
-
size
int size()
Gets the number of elements in the compound.- Returns:
- the number of elements in the compound
- Since:
- 4.15.0
-
getBoolean
default boolean getBoolean(@NotNull @NotNull java.lang.String key)
Gets a boolean.Booleans are stored as a
ByteBinaryTag
with a value of0
forfalse
and1
fortrue
.- Parameters:
key
- the key- Returns:
- the boolean value, or
false
if this compound does not contain a boolean tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getBoolean
default boolean getBoolean(@NotNull @NotNull java.lang.String key, boolean defaultValue)
Gets a boolean.Booleans are stored as a
ByteBinaryTag
with a value of0
forfalse
and1
fortrue
.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the boolean value, or
defaultValue
if this compound does not contain a boolean tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getByte
default byte getByte(@NotNull @NotNull java.lang.String key)
Gets a byte.- Parameters:
key
- the key- Returns:
- the byte value, or
0
if this compound does not contain a byte tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getByte
byte getByte(@NotNull @NotNull java.lang.String key, byte defaultValue)
Gets a byte.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the byte value, or
defaultValue
if this compound does not contain a byte tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getShort
default short getShort(@NotNull @NotNull java.lang.String key)
Gets a short.- Parameters:
key
- the key- Returns:
- the short value, or
0
if this compound does not contain a short tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getShort
short getShort(@NotNull @NotNull java.lang.String key, short defaultValue)
Gets a short.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the short value, or
defaultValue
if this compound does not contain a short tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getInt
default int getInt(@NotNull @NotNull java.lang.String key)
Gets an int.- Parameters:
key
- the key- Returns:
- the int value, or
0
if this compound does not contain an int tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getInt
int getInt(@NotNull @NotNull java.lang.String key, int defaultValue)
Gets an int.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the int value, or
defaultValue
if this compound does not contain an int tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getLong
default long getLong(@NotNull @NotNull java.lang.String key)
Gets a long.- Parameters:
key
- the key- Returns:
- the long value, or
0
if this compound does not contain a long tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getLong
long getLong(@NotNull @NotNull java.lang.String key, long defaultValue)
Gets a long.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the long value, or
defaultValue
if this compound does not contain a long tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getFloat
default float getFloat(@NotNull @NotNull java.lang.String key)
Gets a float.- Parameters:
key
- the key- Returns:
- the float value, or
0
if this compound does not contain a float tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getFloat
float getFloat(@NotNull @NotNull java.lang.String key, float defaultValue)
Gets a float.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the float value, or
defaultValue
if this compound does not contain a float tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getDouble
default double getDouble(@NotNull @NotNull java.lang.String key)
Gets a double.- Parameters:
key
- the key- Returns:
- the double value, or
0
if this compound does not contain a double tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getDouble
double getDouble(@NotNull @NotNull java.lang.String key, double defaultValue)
Gets a double.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the double value, or
defaultValue
if this compound does not contain a double tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getByteArray
byte @NotNull [] getByteArray(@NotNull @NotNull java.lang.String key)
Gets an array of bytes.- Parameters:
key
- the key- Returns:
- the array of bytes, or a zero-length array if this compound does not contain a byte array tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getByteArray
byte @NotNull [] getByteArray(@NotNull @NotNull java.lang.String key, byte @NotNull [] defaultValue)
Gets an array of bytes.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the array of bytes, or
defaultValue
- Since:
- 4.0.0
-
getString
@NotNull default @NotNull java.lang.String getString(@NotNull @NotNull java.lang.String key)
Gets a string.- Parameters:
key
- the key- Returns:
- the string value, or
""
if this compound does not contain a string tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getString
@NotNull @NotNull java.lang.String getString(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String defaultValue)
Gets a string.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the string value, or
defaultValue
if this compound does not contain a string tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getList
@NotNull default @NotNull ListBinaryTag getList(@NotNull @NotNull java.lang.String key)
Gets a list.- Parameters:
key
- the key- Returns:
- the list, or a new list if this compound does not contain a list tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getList
@NotNull @NotNull ListBinaryTag getList(@NotNull @NotNull java.lang.String key, @NotNull @NotNull ListBinaryTag defaultValue)
Gets a list.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the list, or
defaultValue
if this compound does not contain a list tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getList
@NotNull default @NotNull ListBinaryTag getList(@NotNull @NotNull java.lang.String key, @NotNull @NotNull BinaryTagType<? extends BinaryTag> expectedType)
Gets a list, ensuring that the type is the same astype
.- Parameters:
key
- the keyexpectedType
- the expected list type- Returns:
- the list, or a new list if this compound does not contain a list tag
with the specified key, has a tag with a different type, or the
list type
does not matchexpectedType
- Since:
- 4.0.0
-
getList
@NotNull @NotNull ListBinaryTag getList(@NotNull @NotNull java.lang.String key, @NotNull @NotNull BinaryTagType<? extends BinaryTag> expectedType, @NotNull @NotNull ListBinaryTag defaultValue)
Gets a list, ensuring that the type is the same astype
.- Parameters:
key
- the keyexpectedType
- the expected list typedefaultValue
- the default value- Returns:
- the list, or
defaultValue
if this compound does not contain a list tag with the specified key, has a tag with a different type, or thelist type
does not matchexpectedType
- Since:
- 4.0.0
-
getCompound
@NotNull default @NotNull CompoundBinaryTag getCompound(@NotNull @NotNull java.lang.String key)
Gets a compound.- Parameters:
key
- the key- Returns:
- the compound, or a new compound if this compound does not contain a compound tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getCompound
@NotNull @NotNull CompoundBinaryTag getCompound(@NotNull @NotNull java.lang.String key, @NotNull @NotNull CompoundBinaryTag defaultValue)
Gets a compound.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the compound, or
defaultValue
if this compound does not contain a compound tag with the specified key, or has a tag with a different type - Since:
- 4.0.0
-
getIntArray
int @NotNull [] getIntArray(@NotNull @NotNull java.lang.String key)
Gets an array of ints.- Parameters:
key
- the key- Returns:
- the array of ints, or a zero-length array if this compound does not contain a int array tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getIntArray
int @NotNull [] getIntArray(@NotNull @NotNull java.lang.String key, int @NotNull [] defaultValue)
Gets an array of ints.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the array of ints, or
defaultValue
- Since:
- 4.0.0
-
getLongArray
long @NotNull [] getLongArray(@NotNull @NotNull java.lang.String key)
Gets an array of longs.- Parameters:
key
- the key- Returns:
- the array of longs, or a zero-length array if this compound does not contain a long array tag with the specified key, or has a tag with a different type
- Since:
- 4.0.0
-
getLongArray
long @NotNull [] getLongArray(@NotNull @NotNull java.lang.String key, long @NotNull [] defaultValue)
Gets an array of longs.- Parameters:
key
- the keydefaultValue
- the default value- Returns:
- the array of longs, or
defaultValue
- Since:
- 4.0.0
-
-