Class PersistentDataAPI
java.lang.Object
io.github.bakedlibs.dough.data.persistent.PersistentDataAPI
This is a utility class that allows you to modify data for any Objects
that implement
PersistentDataHolder.- Author:
- Walshy, TheBusyBiscuit
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,Z> Z get(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type) Get an object based on the providedPersistentDataTypein aPersistentDataContainer, if the key doesn't exist it returns null.static <T,Z> Z get(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type, Z defaultVal) Get an object based on the providedPersistentDataTypein aPersistentDataContaineror the default value if the key doesn't exist.static booleangetBoolean(PersistentDataHolder holder, NamespacedKey key) Get a byte value in aPersistentDataContaineror the default value passed if no key exists.static bytegetByte(PersistentDataHolder holder, NamespacedKey key) Get a byte value in aPersistentDataContainer, if the key doesn't exist it returns -1.static bytegetByte(PersistentDataHolder holder, NamespacedKey key, byte defaultVal) Get a byte value in aPersistentDataContaineror the default value passed if no key exists.static byte[]getByteArray(PersistentDataHolder holder, NamespacedKey key) Get a byte array in aPersistentDataContainer, if the key doesn't exist it returns null.static byte[]getByteArray(PersistentDataHolder holder, NamespacedKey key, byte... defaultVal) Get a byte array in aPersistentDataContaineror the default value passed if no key exists.static PersistentDataContainergetContainer(PersistentDataHolder holder, NamespacedKey key) Get a nestedPersistentDataContainer, if the key doesn't exist it returns null.static PersistentDataContainergetContainer(PersistentDataHolder holder, NamespacedKey key, PersistentDataContainer defaultVal) Get a nestedPersistentDataContaineror the default value passed if no key exists.static doublegetDouble(PersistentDataHolder holder, NamespacedKey key) Get a double value in aPersistentDataContainer, if the key doesn't exist it returns -1.static doublegetDouble(PersistentDataHolder holder, NamespacedKey key, double defaultVal) Get a double value in aPersistentDataContaineror the default value passed if no key exists.static floatgetFloat(PersistentDataHolder holder, NamespacedKey key) Get a float value in aPersistentDataContainer, if the key doesn't exist it returns -1.static floatgetFloat(PersistentDataHolder holder, NamespacedKey key, float defaultVal) Get a float value in aPersistentDataContaineror the default value passed if no key exists.static intgetInt(PersistentDataHolder holder, NamespacedKey key) Get an integer value in aPersistentDataContainer, if the key doesn't exist it returns -1.static intgetInt(PersistentDataHolder holder, NamespacedKey key, int defaultVal) Get an integer value in aPersistentDataContaineror the default value passed if no key exists.static int[]getIntArray(PersistentDataHolder holder, NamespacedKey key) Get a integer array in aPersistentDataContainer, if the key doesn't exist it returns null.static int[]getIntArray(PersistentDataHolder holder, NamespacedKey key, int... defaultVal) Get a byte array in aPersistentDataContaineror the default value passed if no key exists.static com.google.gson.JsonArraygetJsonArray(PersistentDataHolder holder, NamespacedKey key) Get aJsonArrayin aPersistentDataContainer, if the key doesn't exist it returns null.static com.google.gson.JsonArraygetJsonArray(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonArray defaultVal) Get aJsonArrayin aPersistentDataContaineror the default value passed if no key exists.static com.google.gson.JsonObjectgetJsonObject(PersistentDataHolder holder, NamespacedKey key) Get aJsonObjectin aPersistentDataContainer, if the key doesn't exist it returns null.static com.google.gson.JsonObjectgetJsonObject(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonObject defaultVal) Get aJsonObjectin aPersistentDataContaineror the default value passed if no key exists.static longgetLong(PersistentDataHolder holder, NamespacedKey key) Get a long value in aPersistentDataContainer, if the key doesn't exist it returns -1.static longgetLong(PersistentDataHolder holder, NamespacedKey key, long defaultVal) Get a long value in aPersistentDataContaineror the default value passed if no key exists.static long[]getLongArray(PersistentDataHolder holder, NamespacedKey key) Get a long array in aPersistentDataContainer, if the key doesn't exist it returns null.static long[]getLongArray(PersistentDataHolder holder, NamespacedKey key, long... defaultVal) Get a long array in aPersistentDataContaineror the default value passed if no key exists.static <T,Z> Optional<Z> getOptional(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type) This method returns anOptionaldescribing the object defined by thePersistentDataTypefound under the given key.getOptionalBoolean(PersistentDataHolder holder, NamespacedKey key) getOptionalByte(PersistentDataHolder holder, NamespacedKey key) static Optional<byte[]>getOptionalByteArray(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing the Byte Array found under the given key.static Optional<PersistentDataContainer>getOptionalContainer(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing thePersistentDataContainerfound under the given key.static OptionalDoublegetOptionalDouble(PersistentDataHolder holder, NamespacedKey key) getOptionalFloat(PersistentDataHolder holder, NamespacedKey key) static OptionalIntgetOptionalInt(PersistentDataHolder holder, NamespacedKey key) static Optional<int[]>getOptionalIntArray(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing the Integer Array found under the given key.static Optional<com.google.gson.JsonArray>getOptionalJsonArray(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing theJsonArrayfound under the given key.static Optional<com.google.gson.JsonObject>getOptionalJsonObject(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing theJsonObjectfound under the given key.static OptionalLonggetOptionalLong(PersistentDataHolder holder, NamespacedKey key) static Optional<long[]>getOptionalLongArray(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing the Long Array found under the given key.getOptionalShort(PersistentDataHolder holder, NamespacedKey key) getOptionalString(PersistentDataHolder holder, NamespacedKey key) getOptionalUUID(PersistentDataHolder holder, NamespacedKey key) static shortgetShort(PersistentDataHolder holder, NamespacedKey key) Get a short value in aPersistentDataContainer, if the key doesn't exist it returns -1.static shortgetShort(PersistentDataHolder holder, NamespacedKey key, short defaultVal) Get a short value in aPersistentDataContaineror the default value passed if no key exists.static StringgetString(PersistentDataHolder holder, NamespacedKey key) Get a String value in aPersistentDataContainer, if the key doesn't exist it returns null.static StringgetString(PersistentDataHolder holder, NamespacedKey key, String defaultVal) Get a String value in aPersistentDataContaineror the default value passed if no key exists.static UUIDgetUUID(PersistentDataHolder holder, NamespacedKey key) Get aUUIDin aPersistentDataContainer, if the key doesn't exist it returns null.static <T,Z> boolean has(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.static booleanhasBoolean(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.static booleanhasByte(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a byte with the specified key.static booleanhasByteArray(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a byte array with the specified key.static booleanhasContainer(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.static booleanhasDouble(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a double with the specified key.static booleanhasFloat(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a float with the specified key.static booleanhasInt(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas an integer with the specified key.static booleanhasIntArray(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas an integer array with the specified key.static booleanhasJsonArray(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.static booleanhasJsonObject(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.static booleanhasLong(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a long with the specified key.static booleanhasLongArray(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a long array with the specified key.static booleanhasShort(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a short with the specified key.static booleanhasString(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas a String with the specified key.static booleanhasUUID(PersistentDataHolder holder, NamespacedKey key) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.static voidremove(PersistentDataHolder holder, NamespacedKey key) This removes the data stored with the given key on the given data holderstatic <T,Z> void set(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type, Z obj) Set a custom object based on the givenPersistentDataTypein aPersistentDataContainerstatic voidsetBoolean(PersistentDataHolder holder, NamespacedKey key, boolean value) static voidsetByte(PersistentDataHolder holder, NamespacedKey key, byte value) static voidsetByteArray(PersistentDataHolder holder, NamespacedKey key, byte... value) static voidsetContainer(PersistentDataHolder holder, NamespacedKey key, PersistentDataContainer value) static voidsetDouble(PersistentDataHolder holder, NamespacedKey key, double value) static voidsetFloat(PersistentDataHolder holder, NamespacedKey key, float value) static voidsetInt(PersistentDataHolder holder, NamespacedKey key, int value) static voidsetIntArray(PersistentDataHolder holder, NamespacedKey key, int... value) static voidsetJsonArray(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonArray value) static voidsetJsonObject(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonObject value) static voidsetLong(PersistentDataHolder holder, NamespacedKey key, long value) static voidsetLongArray(PersistentDataHolder holder, NamespacedKey key, long... value) static voidsetShort(PersistentDataHolder holder, NamespacedKey key, short value) static voidsetString(PersistentDataHolder holder, NamespacedKey key, String value) static voidsetUUID(PersistentDataHolder holder, NamespacedKey key, UUID uuid) Set aUUIDin aPersistentDataContainer, split as the 2 longs containing its bits.
-
Method Details
-
setByte
-
setShort
-
setInt
-
setLong
-
setFloat
-
setDouble
-
setString
-
setByteArray
-
setIntArray
-
setLongArray
-
setContainer
public static void setContainer(PersistentDataHolder holder, NamespacedKey key, PersistentDataContainer value) -
setBoolean
-
setJsonObject
public static void setJsonObject(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonObject value) -
setJsonArray
public static void setJsonArray(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonArray value) -
setUUID
public static void setUUID(@Nonnull PersistentDataHolder holder, @Nonnull NamespacedKey key, @Nonnull UUID uuid) Set aUUIDin aPersistentDataContainer, split as the 2 longs containing its bits.- Parameters:
holder- ThePersistentDataHolderto add the data tokey- The key of the data to setuuid- The uuid to put in the container
-
set
@ParametersAreNonnullByDefault public static <T,Z> void set(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type, Z obj) Set a custom object based on the givenPersistentDataTypein aPersistentDataContainer- Parameters:
holder- ThePersistentDataHolderto add the data tokey- The key of the data to settype- ThePersistentDataTypeto be used.obj- The object to put in the container
-
hasByte
Checks if the specifiedPersistentDataHolderhas a byte with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a byte with the specified key.
-
hasShort
Checks if the specifiedPersistentDataHolderhas a short with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a short with the specified key.
-
hasInt
Checks if the specifiedPersistentDataHolderhas an integer with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has an integer with the specified key.
-
hasLong
Checks if the specifiedPersistentDataHolderhas a long with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a long with the specified key.
-
hasFloat
Checks if the specifiedPersistentDataHolderhas a float with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a float with the specified key.
-
hasDouble
Checks if the specifiedPersistentDataHolderhas a double with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a double with the specified key.
-
hasString
Checks if the specifiedPersistentDataHolderhas a String with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a String with the specified key.
-
hasByteArray
Checks if the specifiedPersistentDataHolderhas a byte array with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a byte array with the specified key.
-
hasIntArray
Checks if the specifiedPersistentDataHolderhas an integer array with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has an integer array with the specified key.
-
hasLongArray
Checks if the specifiedPersistentDataHolderhas a long array with the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has a long array with the specified key.
-
hasContainer
Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has aPersistentDataContainerwith the specified key.
-
hasBoolean
Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has aPersistentDataContainerwith the specified key.
-
hasJsonObject
Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has aPersistentDataContainerwith the specified key.
-
hasJsonArray
Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has aPersistentDataContainerwith the specified key.
-
hasUUID
Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has aPersistentDataContainerwith the specified key.
-
has
@ParametersAreNonnullByDefault public static <T,Z> boolean has(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type) Checks if the specifiedPersistentDataHolderhas aPersistentDataContainerwith the specified key.- Parameters:
holder- ThePersistentDataHolderto checkkey- The key to check for- Returns:
trueif the holder has aPersistentDataContainerwith the specified key.
-
getByte
Get a byte value in aPersistentDataContainer, if the key doesn't exist it returns -1.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The byte associated with this key or -1 if it doesn't exist
-
getOptionalByte
This method returns anOptionaldescribing theBytefound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getByte
Get a byte value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The byte associated with this key or the default value if it doesn't exist
-
getOptionalBoolean
This method returns anOptionaldescribing theBytefound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getBoolean
Get a byte value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The byte associated with this key or the default value if it doesn't exist
-
getShort
Get a short value in aPersistentDataContainer, if the key doesn't exist it returns -1.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The short associated with this key or -1 if it doesn't exist
-
getOptionalShort
This method returns anOptionaldescribing theShortfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getShort
Get a short value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The short associated with this key or the default value if it doesn't exist
-
getInt
Get an integer value in aPersistentDataContainer, if the key doesn't exist it returns -1.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The integer associated with this key or -1 if it doesn't exist
-
getOptionalInt
This method returns anOptionaldescribing theIntegerfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getInt
Get an integer value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The integer associated with this key or the default value if it doesn't exist
-
getLong
Get a long value in aPersistentDataContainer, if the key doesn't exist it returns -1.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The long associated with this key or -1 if it doesn't exist
-
getOptionalLong
This method returns anOptionaldescribing theLongfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getLong
Get a long value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The long associated with this key or the default value if it doesn't exist
-
getFloat
Get a float value in aPersistentDataContainer, if the key doesn't exist it returns -1.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The float associated with this key or -1 if it doesn't exist
-
getOptionalFloat
This method returns anOptionaldescribing theFloatfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getFloat
Get a float value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The float associated with this key or the default value if it doesn't exist
-
getDouble
Get a double value in aPersistentDataContainer, if the key doesn't exist it returns -1.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The double associated with this key or -1 if it doesn't exist
-
getOptionalDouble
This method returns anOptionaldescribing theDoublefound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getDouble
Get a double value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The double associated with this key or the default value if it doesn't exist
-
getString
Get a String value in aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The String associated with this key or null if it doesn't exist
-
getOptionalString
This method returns anOptionaldescribing theStringfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getString
Get a String value in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The String associated with this key or the default value if it doesn't exist
-
getByteArray
Get a byte array in aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The byte array associated with this key or null if it doesn't exist
-
getOptionalByteArray
This method returns anOptionaldescribing the Byte Array found under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getByteArray
public static byte[] getByteArray(PersistentDataHolder holder, NamespacedKey key, byte... defaultVal) Get a byte array in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The byte array associated with this key or the default value if it doesn't exist
-
getIntArray
Get a integer array in aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The integer array associated with this key or null if it doesn't exist
-
getOptionalIntArray
This method returns anOptionaldescribing the Integer Array found under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getIntArray
Get a byte array in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The byte associated with this key or the default value if it doesn't exist
-
getLongArray
Get a long array in aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The long array associated with this key or null if it doesn't exist
-
getOptionalLongArray
This method returns anOptionaldescribing the Long Array found under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getLongArray
public static long[] getLongArray(PersistentDataHolder holder, NamespacedKey key, long... defaultVal) Get a long array in aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The long array associated with this key or the default value if it doesn't exist
-
getContainer
Get a nestedPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The byte associated with this key or null if it doesn't exist
-
getOptionalContainer
public static Optional<PersistentDataContainer> getOptionalContainer(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing thePersistentDataContainerfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getContainer
public static PersistentDataContainer getContainer(PersistentDataHolder holder, NamespacedKey key, PersistentDataContainer defaultVal) Get a nestedPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The byte associated with this key or the default value if it doesn't exist
-
getJsonObject
public static com.google.gson.JsonObject getJsonObject(PersistentDataHolder holder, NamespacedKey key) Get aJsonObjectin aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The long array associated with this key or null if it doesn't exist
-
getOptionalJsonObject
public static Optional<com.google.gson.JsonObject> getOptionalJsonObject(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing theJsonObjectfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getJsonObject
public static com.google.gson.JsonObject getJsonObject(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonObject defaultVal) Get aJsonObjectin aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The long array associated with this key or the default value if it doesn't exist
-
getJsonArray
public static com.google.gson.JsonArray getJsonArray(PersistentDataHolder holder, NamespacedKey key) Get aJsonArrayin aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The long array associated with this key or null if it doesn't exist
-
getOptionalJsonArray
public static Optional<com.google.gson.JsonArray> getOptionalJsonArray(PersistentDataHolder holder, NamespacedKey key) This method returns anOptionaldescribing theJsonArrayfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An Optional describing the result
- See Also:
-
getJsonArray
public static com.google.gson.JsonArray getJsonArray(PersistentDataHolder holder, NamespacedKey key, com.google.gson.JsonArray defaultVal) Get aJsonArrayin aPersistentDataContaineror the default value passed if no key exists.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The long array associated with this key or the default value if it doesn't exist
-
getUUID
@Nullable public static UUID getUUID(@Nonnull PersistentDataHolder holder, @Nonnull NamespacedKey key) Get aUUIDin aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- The UUID associated with this key or null if it doesn't exist
-
getOptionalUUID
@Nonnull public static Optional<UUID> getOptionalUUID(@Nonnull PersistentDataHolder holder, @Nonnull NamespacedKey key) This method returns anOptionaldescribing theUUIDfound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An
Optionaldescribing the result - See Also:
-
get
@Nullable @ParametersAreNonnullByDefault public static <T,Z> Z get(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type) Get an object based on the providedPersistentDataTypein aPersistentDataContainer, if the key doesn't exist it returns null.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An object associated with this key or null if it doesn't exist
-
get
@Nonnull @ParametersAreNonnullByDefault public static <T,Z> Z get(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type, Z defaultVal) Get an object based on the providedPersistentDataTypein aPersistentDataContaineror the default value if the key doesn't exist.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrievedefaultVal- The default value to use if no key is found- Returns:
- The object associated with this key or the default value if it doesn't exist
-
remove
This removes the data stored with the given key on the given data holder- Parameters:
holder- ThePersistentDataHolderto remove the data fromkey- The key of the data to remove
-
getOptional
@Nonnull @ParametersAreNonnullByDefault public static <T,Z> Optional<Z> getOptional(PersistentDataHolder holder, NamespacedKey key, PersistentDataType<T, Z> type) This method returns anOptionaldescribing the object defined by thePersistentDataTypefound under the given key. An emptyOptionalwill be returned if no value has been found.- Parameters:
holder- ThePersistentDataHolderto retrieve the data fromkey- The key of the data to retrieve- Returns:
- An
Optionaldescribing the result - See Also:
-