Package org.bukkit.inventory.meta.tags
Interface ItemTagType<T,Z>
- Type Parameters:
T- the primary object type that is stored in the given tagZ- the retrieved object type when applying this item tag type
- All Known Implementing Classes:
ItemTagType.PrimitiveTagType
Deprecated.
This class represents an enum with a generic content type. It defines the
types a custom item tag can have.
This interface can be used to create your own custom ItemTagType with
different complex types. This may be useful for the likes of a
UUIDItemTagType:
public class UUIDItemTagType implements ItemTagType<byte[], UUID> {
{@literal @Override}
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
{@literal @Override}
public Class<UUID> getComplexType() {
return UUID.class;
}
{@literal @Override}
public byte[] toPrimitive(UUID complex, ItemTagAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
bb.putLong(complex.getMostSignificantBits());
bb.putLong(complex.getLeastSignificantBits());
return bb.array();
}
{@literal @Override}
public UUID fromPrimitive(byte[] primitive, ItemTagAdapterContext context) {
ByteBuffer bb = ByteBuffer.wrap(primitive);
long firstLong = bb.getLong();
long secondLong = bb.getLong();
return new UUID(firstLong, secondLong);
}
}-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classDeprecated.A default implementation that simply exists to pass on the retrieved or inserted value to the next layer. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ItemTagType<Byte,Byte> Deprecated.static final ItemTagType<byte[],byte[]> Deprecated.static final ItemTagType<Double,Double> Deprecated.static final ItemTagType<Float,Float> Deprecated.static final ItemTagType<Integer,Integer> Deprecated.static final ItemTagType<int[],int[]> Deprecated.static final ItemTagType<Long,Long> Deprecated.static final ItemTagType<long[],long[]> Deprecated.static final ItemTagType<Short,Short> Deprecated.static final ItemTagType<String,String> Deprecated.static final ItemTagType<CustomItemTagContainer,CustomItemTagContainer> Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionfromPrimitive(T primitive, @NotNull ItemTagAdapterContext context) Deprecated.Creates a complex object based of the passed primitive valueDeprecated.Returns the complex object type the primitive value resembles.Deprecated.Returns the primitive data type of this tag.toPrimitive(Z complex, @NotNull ItemTagAdapterContext context) Deprecated.Returns the primitive data that resembles the complex object passed to this method.
-
Field Details
-
BYTE
Deprecated. -
SHORT
Deprecated. -
INTEGER
Deprecated. -
LONG
Deprecated. -
FLOAT
Deprecated. -
DOUBLE
Deprecated. -
STRING
Deprecated. -
BYTE_ARRAY
Deprecated. -
INTEGER_ARRAY
Deprecated. -
LONG_ARRAY
Deprecated. -
TAG_CONTAINER
Deprecated.
-
-
Method Details
-
getPrimitiveType
Deprecated.Returns the primitive data type of this tag.- Returns:
- the class
-
getComplexType
Deprecated.Returns the complex object type the primitive value resembles.- Returns:
- the class type
-
toPrimitive
Deprecated.Returns the primitive data that resembles the complex object passed to this method.- Parameters:
complex- the complex object instancecontext- the context this operation is running in- Returns:
- the primitive value
-
fromPrimitive
Deprecated.Creates a complex object based of the passed primitive value- Parameters:
primitive- the primitive valuecontext- the context this operation is running in- Returns:
- the complex object instance
-
PersistentDataTypeas this part of the api is being replaced