Package org.bukkit.persistence
Interface PersistentDataContainer
- All Superinterfaces:
PersistentDataContainerView
This interface represents a map like object, capable of storing custom tags
in it.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidreadFromBytes(byte @NotNull [] bytes) Read values from a serialised byte array into thisPersistentDataContainerinstance.voidreadFromBytes(byte @NotNull [] bytes, boolean clear) Read values from a serialised byte array into thisPersistentDataContainerinstance.voidremove(@NotNull NamespacedKey key) Removes a custom key from thePersistentDataHolderinstance.<P,C> void set(@NotNull NamespacedKey key, @NotNull PersistentDataType<P, C> type, C value) Stores a metadata value on thePersistentDataHolderinstance.Methods inherited from interface io.papermc.paper.persistence.PersistentDataContainerView
copyTo, get, getAdapterContext, getKeys, getOrDefault, has, has, isEmpty, serializeToBytes
-
Method Details
-
set
<P,C> void set(@NotNull @NotNull NamespacedKey key, @NotNull @NotNull PersistentDataType<P, C> type, @NotNull C value) Stores a metadata value on thePersistentDataHolderinstance.This API cannot be used to manipulate minecraft data, as the values will be stored using your namespace. This method will override any existing value the
PersistentDataHoldermay have stored under the provided key.- Type Parameters:
P- the generic java type of the tag valueC- the generic type of the object to store- Parameters:
key- the key this value will be stored undertype- the type this tag usesvalue- the value to store in the tag- Throws:
IllegalArgumentException- if the key is nullIllegalArgumentException- if the type is nullIllegalArgumentException- if the value is null. Removing a tag should be done usingremove(NamespacedKey)IllegalArgumentException- if no suitable adapter was found for thePersistentDataType.getPrimitiveType()
-
remove
Removes a custom key from thePersistentDataHolderinstance.- Parameters:
key- the key to remove- Throws:
IllegalArgumentException- if the provided key is null
-
readFromBytes
Read values from a serialised byte array into thisPersistentDataContainerinstance.- Parameters:
bytes- the byte array to read fromclear- if true, thisPersistentDataContainerinstance will be cleared before reading- Throws:
IOException- if the byte array has an invalid format
-
readFromBytes
Read values from a serialised byte array into thisPersistentDataContainerinstance. This method has the same effect asPersistentDataContainer#readFromBytes(bytes, true)- Parameters:
bytes- the byte array to read from- Throws:
IOException- if the byte array has an invalid format
-