Interface ItemTagType<T,Z>

Type Parameters:
T - the primary object type that is stored in the given tag
Z - the retrieved object type when applying this item tag type
All Known Implementing Classes:
ItemTagType.PrimitiveTagType

@Deprecated(since="1.14", forRemoval=true) public interface ItemTagType<T,Z>
Deprecated, for removal: This API element is subject to removal in a future version.
please use PersistentDataType as this part of the api is being replaced
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 Classes
    Modifier and Type
    Interface
    Description
    static class 
    Deprecated, for removal: This API element is subject to removal in a future version.
    A default implementation that simply exists to pass on the retrieved or inserted value to the next layer.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ItemTagType<Byte,Byte>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<byte[],byte[]>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<Double,Double>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<Float,Float>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<int[],int[]>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<Long,Long>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<long[],long[]>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<Short,Short>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    static final ItemTagType<String,String>
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a complex object based of the passed primitive value
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the complex object type the primitive value resembles.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the primitive data type of this tag.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the primitive data that resembles the complex object passed to this method.
  • Field Details

    • BYTE

      static final ItemTagType<Byte,Byte> BYTE
      Deprecated, for removal: This API element is subject to removal in a future version.
    • SHORT

      static final ItemTagType<Short,Short> SHORT
      Deprecated, for removal: This API element is subject to removal in a future version.
    • INTEGER

      static final ItemTagType<Integer,Integer> INTEGER
      Deprecated, for removal: This API element is subject to removal in a future version.
    • LONG

      static final ItemTagType<Long,Long> LONG
      Deprecated, for removal: This API element is subject to removal in a future version.
    • FLOAT

      static final ItemTagType<Float,Float> FLOAT
      Deprecated, for removal: This API element is subject to removal in a future version.
    • DOUBLE

      static final ItemTagType<Double,Double> DOUBLE
      Deprecated, for removal: This API element is subject to removal in a future version.
    • STRING

      static final ItemTagType<String,String> STRING
      Deprecated, for removal: This API element is subject to removal in a future version.
    • BYTE_ARRAY

      static final ItemTagType<byte[],byte[]> BYTE_ARRAY
      Deprecated, for removal: This API element is subject to removal in a future version.
    • INTEGER_ARRAY

      static final ItemTagType<int[],int[]> INTEGER_ARRAY
      Deprecated, for removal: This API element is subject to removal in a future version.
    • LONG_ARRAY

      static final ItemTagType<long[],long[]> LONG_ARRAY
      Deprecated, for removal: This API element is subject to removal in a future version.
    • TAG_CONTAINER

      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • getPrimitiveType

      @NotNull @NotNull Class<T> getPrimitiveType()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the primitive data type of this tag.
      Returns:
      the class
    • getComplexType

      @NotNull @NotNull Class<Z> getComplexType()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the complex object type the primitive value resembles.
      Returns:
      the class type
    • toPrimitive

      @NotNull T toPrimitive(@NotNull Z complex, @NotNull @NotNull ItemTagAdapterContext context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the primitive data that resembles the complex object passed to this method.
      Parameters:
      complex - the complex object instance
      context - the context this operation is running in
      Returns:
      the primitive value
    • fromPrimitive

      @NotNull Z fromPrimitive(@NotNull T primitive, @NotNull @NotNull ItemTagAdapterContext context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a complex object based of the passed primitive value
      Parameters:
      primitive - the primitive value
      context - the context this operation is running in
      Returns:
      the complex object instance