Class PDCTag

java.lang.Object
com.github.darksoulq.abyssallib.world.util.PDCTag

public class PDCTag extends Object
A wrapper for Bukkit's PersistentDataContainer (PDC) API.

This class simplifies data persistence on Bukkit objects (like ItemMeta, Entities, and TileEntities) by abstracting PersistentDataType handling and utilizing NamespacedKey for key management.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PDCTag(org.bukkit.persistence.PersistentDataContainer container)
    Constructs a new PDCTag wrapper for a specific container.
  • Method Summary

    Modifier and Type
    Method
    Description
    getBoolean(org.bukkit.NamespacedKey key)
    Retrieves a Boolean value from the container.
    getByte(org.bukkit.NamespacedKey key)
    Retrieves a Byte value from the container.
    Optional<byte[]>
    getByteArray(org.bukkit.NamespacedKey key)
    Retrieves a Byte array from the container.
    getFloat(org.bukkit.NamespacedKey key)
    Retrieves a Float value from the container.
    getInt(org.bukkit.NamespacedKey key)
    Retrieves an Integer value from the container.
    Optional<int[]>
    getIntArray(org.bukkit.NamespacedKey key)
    Retrieves an Integer array from the container.
    getString(org.bukkit.NamespacedKey key)
    Retrieves a String value from the container.
    void
    set(org.bukkit.NamespacedKey key, boolean value)
    Stores a boolean value in the container.
    void
    set(org.bukkit.NamespacedKey key, byte value)
    Stores a byte value in the container.
    void
    set(org.bukkit.NamespacedKey key, byte[] value)
    Stores a byte array in the container.
    void
    set(org.bukkit.NamespacedKey key, float value)
    Stores a float value in the container.
    void
    set(org.bukkit.NamespacedKey key, int value)
    Stores an integer value in the container.
    void
    set(org.bukkit.NamespacedKey key, int[] value)
    Stores an integer array in the container.
    void
    set(org.bukkit.NamespacedKey key, String value)
    Stores a String value in the container.
    org.bukkit.persistence.PersistentDataContainer
    Returns the raw Bukkit container.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PDCTag

      public PDCTag(org.bukkit.persistence.PersistentDataContainer container)
      Constructs a new PDCTag wrapper for a specific container.
      Parameters:
      container - The PersistentDataContainer to wrap.
  • Method Details

    • set

      public void set(org.bukkit.NamespacedKey key, String value)
      Stores a String value in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The string value to store.
    • set

      public void set(org.bukkit.NamespacedKey key, int value)
      Stores an integer value in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The integer value to store.
    • set

      public void set(org.bukkit.NamespacedKey key, int[] value)
      Stores an integer array in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The integer array to store.
    • set

      public void set(org.bukkit.NamespacedKey key, boolean value)
      Stores a boolean value in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The boolean value to store.
    • set

      public void set(org.bukkit.NamespacedKey key, float value)
      Stores a float value in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The float value to store.
    • set

      public void set(org.bukkit.NamespacedKey key, byte value)
      Stores a byte value in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The byte value to store.
    • set

      public void set(org.bukkit.NamespacedKey key, byte[] value)
      Stores a byte array in the container.
      Parameters:
      key - The unique NamespacedKey key.
      value - The byte array to store.
    • getString

      public Optional<String> getString(org.bukkit.NamespacedKey key)
      Retrieves a String value from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the string value if present.
    • getInt

      public Optional<Integer> getInt(org.bukkit.NamespacedKey key)
      Retrieves an Integer value from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the integer value if present.
    • getIntArray

      public Optional<int[]> getIntArray(org.bukkit.NamespacedKey key)
      Retrieves an Integer array from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the integer array if present.
    • getBoolean

      public Optional<Boolean> getBoolean(org.bukkit.NamespacedKey key)
      Retrieves a Boolean value from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the boolean value if present.
    • getFloat

      public Optional<Float> getFloat(org.bukkit.NamespacedKey key)
      Retrieves a Float value from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the float value if present.
    • getByte

      public Optional<Byte> getByte(org.bukkit.NamespacedKey key)
      Retrieves a Byte value from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the byte value if present.
    • getByteArray

      public Optional<byte[]> getByteArray(org.bukkit.NamespacedKey key)
      Retrieves a Byte array from the container.
      Parameters:
      key - The unique NamespacedKey key.
      Returns:
      An Optional containing the byte array if present.
    • toVanilla

      public org.bukkit.persistence.PersistentDataContainer toVanilla()
      Returns the raw Bukkit container.
      Returns:
      The underlying PersistentDataContainer.