Class PersistentDataType.BooleanPersistentDataType

java.lang.Object
org.bukkit.persistence.PersistentDataType.BooleanPersistentDataType
All Implemented Interfaces:
PersistentDataType<Byte,Boolean>
Enclosing interface:
PersistentDataType<P,C>

public static class PersistentDataType.BooleanPersistentDataType extends Object implements PersistentDataType<Byte,Boolean>
A convenience implementation to convert between Byte and Boolean as there is no native implementation for booleans.
Any byte value not equal to 0 is considered to be true.
Since:
1.19.4
  • Constructor Details

    • BooleanPersistentDataType

      public BooleanPersistentDataType()
  • Method Details

    • getPrimitiveType

      @NotNull public @NotNull Class<Byte> getPrimitiveType()
      Returns the primitive data type of this tag.
      Specified by:
      getPrimitiveType in interface PersistentDataType<Byte,Boolean>
      Returns:
      the class
      Since:
      1.19.4
    • getComplexType

      @NotNull public @NotNull Class<Boolean> getComplexType()
      Returns the complex object type the primitive value resembles.
      Specified by:
      getComplexType in interface PersistentDataType<Byte,Boolean>
      Returns:
      the class type
      Since:
      1.19.4
    • toPrimitive

      @NotNull public @NotNull Byte toPrimitive(@NotNull @NotNull Boolean complex, @NotNull @NotNull PersistentDataAdapterContext context)
      Returns the primitive data that resembles the complex object passed to this method.
      Specified by:
      toPrimitive in interface PersistentDataType<Byte,Boolean>
      Parameters:
      complex - the complex object instance
      context - the context this operation is running in
      Returns:
      the primitive value
      Since:
      1.19.4
    • fromPrimitive

      @NotNull public @NotNull Boolean fromPrimitive(@NotNull @NotNull Byte primitive, @NotNull @NotNull PersistentDataAdapterContext context)
      Creates a complex object based of the passed primitive value
      Specified by:
      fromPrimitive in interface PersistentDataType<Byte,Boolean>
      Parameters:
      primitive - the primitive value
      context - the context this operation is running in
      Returns:
      the complex object instance
      Since:
      1.19.4