Class Tag<T>
java.lang.Object
net.minestom.server.tag.Tag<T>
- Type Parameters:
T- the tag type
Represents a key to retrieve or change a value.
All tags are serializable.
-
Method Summary
Modifier and TypeMethodDescriptiondefaultValue(Supplier<T> defaultValue) defaultValue(T defaultValue) booleangetKey()Returns the key used to navigate inside the holder nbt.inthashCode()list()<R> Tag<R> Creates a flexible tag able to read and write anyBinaryTagobjects.read(CompoundBinaryTag nbt) static <T> Tag<T> Structure(String key, TagSerializer<T> serializer) Creates a tag containing multiple fields.static <T> Tag<T> Creates a transient tag with the specified key.static <T> Tag<T> View(TagSerializer<T> serializer) Specialized Structure tag affecting the src of the handler (i.e.voidwrite(CompoundBinaryTag.Builder nbtCompound, T value) voidwriteUnsafe(CompoundBinaryTag.Builder nbtCompound, @Nullable Object value)
-
Method Details
-
getKey
-
defaultValue
-
defaultValue
-
map
-
list
-
path
-
read
-
write
-
writeUnsafe
-
equals
-
hashCode
-
Byte
-
Boolean
-
Short
-
Integer
-
Long
-
Float
-
Double
-
String
-
UUID
-
ItemStack
-
Component
-
NBT
-
Structure
Creates a tag containing multiple fields.Those fields cannot be modified from an outside tag. (This is to prevent the backed object from becoming out of sync)
- Type Parameters:
T- the tag type- Parameters:
key- the tag keyserializer- the tag serializer- Returns:
- the created tag
-
View
Specialized Structure tag affecting the src of the handler (i.e. overwrite all its data).Must be used with care.
-
Structure
-
View
-
Transient
Creates a transient tag with the specified key. This tag does not get serialized to NBT (Named Binary Tag) format and is not sent to the client. Unlike other tags, which are serialized, transient tags are used for temporary data that only needs to exist on the server side.- Type Parameters:
T- The type of the tag's value.- Parameters:
key- The key.- Returns:
- A transient tag with the key.
-