Package dev.sefiraat.sefilib.persistence
Class BukkitObjectDataType<T extends ConfigurationSerializable>
java.lang.Object
dev.sefiraat.sefilib.persistence.BukkitObjectDataType<T>
- Type Parameters:
T- The type ofConfigurationSerializableto store
- All Implemented Interfaces:
PersistentDataType<byte[],T>
public class BukkitObjectDataType<T extends ConfigurationSerializable>
extends Object
implements PersistentDataType<byte[],T>
This
PersistentDataType can be used to store and retrieve ConfigurationSerializables from
PersistentDataHolders.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bukkit.persistence.PersistentDataType
PersistentDataType.PrimitivePersistentDataType<T extends Object> -
Field Summary
Fields inherited from interface org.bukkit.persistence.PersistentDataType
BYTE, BYTE_ARRAY, DOUBLE, FLOAT, INTEGER, INTEGER_ARRAY, LONG, LONG_ARRAY, SHORT, STRING, TAG_CONTAINER, TAG_CONTAINER_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionBukkitObjectDataType(Class<T> clazz) Creates a newBukkitObjectDataTypefor the givenConfigurationSerializableclass. -
Method Summary
Modifier and TypeMethodDescriptionfromPrimitive(byte[] byteArray, PersistentDataAdapterContext context) Converts the provided byte array to aConfigurationSerializable.Gets theConfigurationSerializableclass that is stored by thisPersistentDataType.Class<byte[]>byte[]toPrimitive(T bukkitObject, PersistentDataAdapterContext context) Converts the providedConfigurationSerializableto a byte array.
-
Constructor Details
-
BukkitObjectDataType
Creates a newBukkitObjectDataTypefor the givenConfigurationSerializableclass.- Parameters:
clazz- TheConfigurationSerializableclass to store
-
-
Method Details
-
getPrimitiveType
- Specified by:
getPrimitiveTypein interfacePersistentDataType<byte[],T extends ConfigurationSerializable> - Returns:
- The
ConfigurationSerializableclass
-
getComplexType
Gets theConfigurationSerializableclass that is stored by thisPersistentDataType.- Specified by:
getComplexTypein interfacePersistentDataType<byte[],T extends ConfigurationSerializable> - Returns:
- The
ConfigurationSerializableclass
-
toPrimitive
@Nonnull public byte[] toPrimitive(@Nonnull T bukkitObject, @Nonnull PersistentDataAdapterContext context) Converts the providedConfigurationSerializableto a byte array.- Specified by:
toPrimitivein interfacePersistentDataType<byte[],T extends ConfigurationSerializable> - Parameters:
bukkitObject- TheConfigurationSerializableto convertcontext- ThePersistentDataAdapterContextto use- Returns:
- The byte array representation of the
ConfigurationSerializable
-
fromPrimitive
@Nonnull @ParametersAreNonnullByDefault public T fromPrimitive(byte[] byteArray, PersistentDataAdapterContext context) Converts the provided byte array to aConfigurationSerializable.- Specified by:
fromPrimitivein interfacePersistentDataType<byte[],T extends ConfigurationSerializable> - Parameters:
byteArray- The byte array to convertcontext- ThePersistentDataAdapterContextto use- Returns:
- The
ConfigurationSerializablerepresentation of the byte array
-