Interface DataType
public interface DataType
Custom
PersistentDataType
s including Collections, Maps, and Arrays.
All data types in this class will work in all Spigot versions since PDC was added (1.14.1+).- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PersistentDataType<byte[],
AttributeModifier> static final PersistentDataType<byte[],
AttributeModifier[]> PersistentDataType
forAttributeModifier
arraysstatic final PersistentDataType<String,
BlockData> static final PersistentDataType<byte[],
BlockData[]> PersistentDataType
forBlockData
arraysstatic final PersistentDataType<byte[],
BlockVector> static final PersistentDataType<byte[],
BlockVector[]> PersistentDataType
forBlockVector
arraysstatic final PersistentDataType<Byte,
Boolean> PersistentDataType
forbyte
sstatic final PersistentDataType<byte[],
boolean[]> PersistentDataType
forboolean
arraysstatic final PersistentDataType<byte[],
BoundingBox> static final PersistentDataType<byte[],
BoundingBox[]> PersistentDataType
forBoundingBox
arraysstatic final PersistentDataType<Byte,
Byte> PersistentDataType
forbyte
sstatic final PersistentDataType<byte[],
byte[]> PersistentDataType
forbyte
arraysstatic final PersistentDataType<Integer,
Character> PersistentDataType
forchar
sstatic final PersistentDataType<int[],
char[]> PersistentDataType
forchar
arraysstatic final PersistentDataType<byte[],
Color> PersistentDataType
forColor
sstatic final PersistentDataType<byte[],
Color[]> PersistentDataType
forColor
arraysstatic final PersistentDataType<byte[],
ConfigurationSerializable> static final PersistentDataType<byte[],
ConfigurationSerializable[]> PersistentDataType
forConfigurationSerializable
arraysstatic final PersistentDataType<Long,
Date> PersistentDataType
forDate
sstatic final PersistentDataType<Double,
Double> PersistentDataType
fordouble
sstatic final PersistentDataType<byte[],
double[]> PersistentDataType
fordouble
arraysstatic final PersistentDataType<String,
FileConfiguration> static final PersistentDataType<byte[],
FireworkEffect> static final PersistentDataType<byte[],
FireworkEffect[]> PersistentDataType
forFireworkEffect
arraysstatic final PersistentDataType<Float,
Float> PersistentDataType
forfloat
sstatic final PersistentDataType<byte[],
float[]> PersistentDataType
forfloat
arraysstatic final PersistentDataType<Integer,
Integer> PersistentDataType
forint
sstatic final PersistentDataType<int[],
int[]> PersistentDataType
forint
arraysstatic final PersistentDataType<byte[],
ItemMeta> static final PersistentDataType<byte[],
ItemMeta[]> PersistentDataType
forItemMeta
arraysstatic final PersistentDataType<byte[],
ItemStack> static final PersistentDataType<byte[],
ItemStack[]> PersistentDataType
forItemStack
arraysstatic final PersistentDataType<byte[],
Location> static final PersistentDataType<byte[],
Location[]> PersistentDataType
forLocation
arraysstatic final PersistentDataType<Long,
Long> PersistentDataType
forlong
sstatic final PersistentDataType<long[],
long[]> PersistentDataType
forlong
arraysstatic final PersistentDataType<byte[],
OfflinePlayer> static final PersistentDataType<byte[],
OfflinePlayer[]> PersistentDataType
forOfflinePlayer
arraysstatic final PersistentDataType<byte[],
Pattern> PersistentDataType
for BannerPattern
sstatic final PersistentDataType<byte[],
Pattern[]> PersistentDataType
for BannerPattern
arraysstatic final PersistentDataType<byte[],
Player> PersistentDataType
forPlayer
sstatic final PersistentDataType<byte[],
Player[]> PersistentDataType
forPlayer
arraysstatic final PersistentDataType<byte[],
PotionEffect> static final PersistentDataType<byte[],
PotionEffect[]> PersistentDataType
forPotionEffect
arraysstatic final PersistentDataType<Short,
Short> PersistentDataType
forshort
sstatic final PersistentDataType<byte[],
short[]> PersistentDataType
forshort
arraysstatic final PersistentDataType<String,
String> PersistentDataType
forString
sstatic final PersistentDataType<byte[],
String[]> PersistentDataType
forString
arraysstatic final PersistentDataType<PersistentDataContainer,
PersistentDataContainer> static final PersistentDataType<PersistentDataContainer[],
PersistentDataContainer[]> PersistentDataType
forPersistentDataContainer
arraysstatic final PersistentDataType<byte[],
UUID> PersistentDataType
forUUID
sstatic final PersistentDataType<byte[],
Vector> PersistentDataType
forVector
sstatic final PersistentDataType<byte[],
Vector[]> PersistentDataType
forVector
arrays -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ArrayDataType<T>
asArray
(T[] array, PersistentDataType<?, T> dataType) Turns an existingPersistentDataType
into one that holds arrays of the same class.static <T> CollectionDataType<ArrayList<T>,
T> asArrayList
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds anArrayList
of the same classstatic <K,
V> MapDataType<ConcurrentHashMap<K, V>, K, V> asConcurrentHashMap
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aConcurrentHashMap
of the given DataTypesstatic <T> CollectionDataType<CopyOnWriteArrayList<T>,
T> asCopyOnWriteArrayList
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aCopyOnWriteArrayList
of the same classstatic <T> CollectionDataType<CopyOnWriteArraySet<T>,
T> asCopyOnWriteArraySet
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aCopyOnWriteArraySet
of the same classstatic <E extends Enum<E>>
PersistentDataType<String,E> Creates aPersistentDataType
for a givenEnum
class.static <E extends Enum<E>,
V>
MapDataType<EnumMap<E,V>, E, V> asEnumMap
(Class<E> enumClazz, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding anEnumMap
of the given Enum Class and DataTypestatic <E extends Enum<E>>
CollectionDataType<EnumSet<E>,E> Returns aPersistentDataType
holding anEnumSet
of the given Enum classstatic <C extends Collection<T>,
T>
CollectionDataType<C,T> asGenericCollection
(Supplier<C> supplier, PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aCollection
of the same classstatic <M extends Map<K,
V>, K, V>
MapDataType<M,K, V> asGenericMap
(Supplier<M> supplier, PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding a specificMap
implementation of the given DataTypes.static <K,
V> MapDataType<HashMap<K, V>, K, V> asHashMap
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aHashMap
of the given DataTypesstatic <T> CollectionDataType<HashSet<T>,
T> asHashSet
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aHashSet
of the same classstatic <K,
V> MapDataType<Hashtable<K, V>, K, V> asHashtable
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aHashtable
of the given DataTypesstatic <K,
V> MapDataType<IdentityHashMap<K, V>, K, V> asIdentityHashMap
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aIdentityHashMap
of the given DataTypesstatic <K,
V> MapDataType<LinkedHashMap<K, V>, K, V> asLinkedHashMap
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aLinkedHashMap
of the given DataTypesstatic <T> CollectionDataType<LinkedList<T>,
T> asLinkedList
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aLinkedList
of the same classstatic <T> CollectionDataType<List<T>,
T> asList
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aList
of the same class.static <K,
V> MapDataType<Map<K, V>, K, V> asMap
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aMap
of the given DataTypesstatic <T> CollectionDataType<Set<T>,
T> asSet
(PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aSet
of the same classstatic <K,
V> MapDataType<TreeMap<K, V>, K, V> asTreeMap
(PersistentDataType<?, K> keyType, PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aTreeMap
of the given DataTypes
-
Field Details
-
ATTRIBUTE_MODIFIER
-
ATTRIBUTE_MODIFIER_ARRAY
PersistentDataType
forAttributeModifier
arrays -
BLOCK_DATA
-
BLOCK_DATA_ARRAY
PersistentDataType
forBlockData
arrays -
BLOCK_VECTOR
-
BLOCK_VECTOR_ARRAY
PersistentDataType
forBlockVector
arrays -
BOUNDING_BOX
-
BOUNDING_BOX_ARRAY
PersistentDataType
forBoundingBox
arrays -
COLOR
PersistentDataType
forColor
s -
COLOR_ARRAY
PersistentDataType
forColor
arrays -
CONFIGURATION_SERIALIZABLE
-
CONFIGURATION_SERIALIZABLE_ARRAY
static final PersistentDataType<byte[],ConfigurationSerializable[]> CONFIGURATION_SERIALIZABLE_ARRAYPersistentDataType
forConfigurationSerializable
arrays -
DATE
PersistentDataType
forDate
s -
FILE_CONFIGURATION
-
FIREWORK_EFFECT
-
FIREWORK_EFFECT_ARRAY
PersistentDataType
forFireworkEffect
arrays -
ITEM_META
-
ITEM_META_ARRAY
PersistentDataType
forItemMeta
arrays -
ITEM_STACK
-
ITEM_STACK_ARRAY
PersistentDataType
forItemStack
arrays -
LOCATION
-
LOCATION_ARRAY
PersistentDataType
forLocation
arrays -
OFFLINE_PLAYER
-
OFFLINE_PLAYER_ARRAY
PersistentDataType
forOfflinePlayer
arrays -
PATTERN
PersistentDataType
for BannerPattern
s -
PATTERN_ARRAY
PersistentDataType
for BannerPattern
arrays -
PLAYER
PersistentDataType
forPlayer
s -
PLAYER_ARRAY
PersistentDataType
forPlayer
arrays -
POTION_EFFECT
-
POTION_EFFECT_ARRAY
PersistentDataType
forPotionEffect
arrays -
UUID
PersistentDataType
forUUID
s -
VECTOR
PersistentDataType
forVector
s -
VECTOR_ARRAY
PersistentDataType
forVector
arrays -
BOOLEAN
PersistentDataType
forbyte
s -
BOOLEAN_ARRAY
PersistentDataType
forboolean
arrays -
CHARACTER
PersistentDataType
forchar
s -
CHARACTER_ARRAY
PersistentDataType
forchar
arrays -
DOUBLE_ARRAY
PersistentDataType
fordouble
arrays -
FLOAT_ARRAY
PersistentDataType
forfloat
arrays -
SHORT_ARRAY
PersistentDataType
forshort
arrays -
STRING_ARRAY
PersistentDataType
forString
arrays -
BYTE
PersistentDataType
forbyte
s -
BYTE_ARRAY
PersistentDataType
forbyte
arrays -
DOUBLE
PersistentDataType
fordouble
s -
FLOAT
PersistentDataType
forfloat
s -
INTEGER
PersistentDataType
forint
s -
INTEGER_ARRAY
PersistentDataType
forint
arrays -
LONG
PersistentDataType
forlong
s -
LONG_ARRAY
PersistentDataType
forlong
arrays -
SHORT
PersistentDataType
forshort
s -
STRING
PersistentDataType
forString
s -
TAG_CONTAINER
-
TAG_CONTAINER_ARRAY
static final PersistentDataType<PersistentDataContainer[],PersistentDataContainer[]> TAG_CONTAINER_ARRAYPersistentDataType
forPersistentDataContainer
arrays
-
-
Method Details
-
asEnum
Creates aPersistentDataType
for a givenEnum
class.- Type Parameters:
E
- enum type- Parameters:
enumClazz
- enum class to get aPersistentDataType
for- Returns:
- a
PersistentDataType
for the given enum class
-
asArray
Turns an existingPersistentDataType
into one that holds arrays of the same class. If a native arrayPersistentDataType
already exists, you should use that one instead of creating a generic one. Also note that the native array DataTypes are not interchangeable with the generic ones created by this method.- Type Parameters:
T
- The type of the array- Parameters:
array
- An (empty) array of the classdataType
- The existing DataType- Returns:
- A
PersistentDataType
that holds arrays of the given class
-
asGenericCollection
static <C extends Collection<T>,T> CollectionDataType<C,T> asGenericCollection(@NotNull Supplier<C> supplier, @NotNull PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aCollection
of the same classExample usage:
PersistentDataType<?,CopyOnWriteArrayList<String>> dataType = DataType.asGenericCollection(CopyOnWriteArrayList<String>::new, DataType.STRING);
- Type Parameters:
C
- The type of the collectionT
- The type of the elements in the collection- Parameters:
supplier
- ASupplier
that returns an empty instance of the given Collection class.type
- The existing DataType- Returns:
- A
PersistentDataType
holding aCollection
-
asList
Turns an existingPersistentDataType
into one that holds aList
of the same class.- Type Parameters:
T
- The type of the elements in the list- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding aList
-
asArrayList
Turns an existingPersistentDataType
into one that holds anArrayList
of the same class- Type Parameters:
T
- The type of the elements in the list- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding anArrayList
-
asLinkedList
Turns an existingPersistentDataType
into one that holds aLinkedList
of the same class- Type Parameters:
T
- The type of the elements in the list- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding aLinkedList
-
asSet
Turns an existingPersistentDataType
into one that holds aSet
of the same class- Type Parameters:
T
- The type of the elements in the set- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding aSet
-
asHashSet
Turns an existingPersistentDataType
into one that holds aHashSet
of the same class- Type Parameters:
T
- The type of the elements in the set- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding aHashSet
-
asCopyOnWriteArrayList
static <T> CollectionDataType<CopyOnWriteArrayList<T>,T> asCopyOnWriteArrayList(@NotNull PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aCopyOnWriteArrayList
of the same class- Type Parameters:
T
- The type of the elements in the list- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding aCopyOnWriteArrayList
-
asCopyOnWriteArraySet
static <T> CollectionDataType<CopyOnWriteArraySet<T>,T> asCopyOnWriteArraySet(@NotNull PersistentDataType<?, T> type) Turns an existingPersistentDataType
into one that holds aCopyOnWriteArraySet
of the same class- Type Parameters:
T
- The type of the elements in the set- Parameters:
type
- The existing DataType- Returns:
- A
PersistentDataType
holding aCopyOnWriteArraySet
-
asEnumSet
Returns aPersistentDataType
holding anEnumSet
of the given Enum class- Type Parameters:
E
- The Enum type- Parameters:
enumClazz
- The Enum class- Returns:
- A
PersistentDataType
holding anEnumSet
of the given Enum class
-
asGenericMap
static <M extends Map<K,V>, MapDataType<M,K, V> K, asGenericMapV> (@NotNull Supplier<M> supplier, @NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding a specificMap
implementation of the given DataTypes.Example usage:
PersistentDataType<?,Hashtable<String,Integer>> dataType = DataType.asGenericMap(Hashtable<String,Integer>::new, DataType.STRING, DataType.INTEGER);
- Type Parameters:
M
- Map typeK
- Key typeV
- Value type- Parameters:
supplier
- ASupplier
that returns an empty instance of the desired Map classkeyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a Map
-
asMap
static <K,V> MapDataType<Map<K,V>, asMapK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aMap
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a Map
-
asHashMap
static <K,V> MapDataType<HashMap<K,V>, asHashMapK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aHashMap
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a HashMap
-
asConcurrentHashMap
static <K,V> MapDataType<ConcurrentHashMap<K,V>, asConcurrentHashMapK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aConcurrentHashMap
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a ConcurrentHashMap
-
asIdentityHashMap
static <K,V> MapDataType<IdentityHashMap<K,V>, asIdentityHashMapK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aIdentityHashMap
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a IdentityHashMap
-
asLinkedHashMap
static <K,V> MapDataType<LinkedHashMap<K,V>, asLinkedHashMapK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aLinkedHashMap
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a LinkedHashMap
-
asTreeMap
static <K,V> MapDataType<TreeMap<K,V>, asTreeMapK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aTreeMap
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a TreeMap
-
asHashtable
static <K,V> MapDataType<Hashtable<K,V>, asHashtableK, V> (@NotNull PersistentDataType<?, K> keyType, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding aHashtable
of the given DataTypes- Type Parameters:
K
- Key typeV
- Value type- Parameters:
keyType
- The existingPersistentDataType
for the map's keysvalueType
- The existingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding a Hashtable
-
asEnumMap
static <E extends Enum<E>,V> MapDataType<EnumMap<E,V>, asEnumMapE, V> (@NotNull Class<E> enumClazz, @NotNull PersistentDataType<?, V> valueType) Creates aPersistentDataType
holding anEnumMap
of the given Enum Class and DataType- Type Parameters:
E
- Enum typeV
- Value type- Parameters:
enumClazz
- Enum classvalueType
- ExistingPersistentDataType
for the map's values- Returns:
- PersistentDataType holding an EnumMap
-