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 void
readFromBytes
(byte @NotNull [] bytes) Read values from a serialised byte array into thisPersistentDataContainer
instance.void
readFromBytes
(byte @NotNull [] bytes, boolean clear) Read values from a serialised byte array into thisPersistentDataContainer
instance.void
remove
(@NotNull NamespacedKey key) Removes a custom key from thePersistentDataHolder
instance.<P,
C> void set
(@NotNull NamespacedKey key, @NotNull PersistentDataType<P, C> type, C value) Stores a metadata value on thePersistentDataHolder
instance.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 thePersistentDataHolder
instance.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
PersistentDataHolder
may 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 thePersistentDataHolder
instance.- Parameters:
key
- the key to remove- Throws:
IllegalArgumentException
- if the provided key is null
-
readFromBytes
Read values from a serialised byte array into thisPersistentDataContainer
instance.- Parameters:
bytes
- the byte array to read fromclear
- if true, thisPersistentDataContainer
instance will be cleared before reading- Throws:
IOException
- if the byte array has an invalid format
-
readFromBytes
Read values from a serialised byte array into thisPersistentDataContainer
instance. 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
-