Class PDCUtils

java.lang.Object
org.skriptlang.skript.bukkit.pdc.PDCUtils

public final class PDCUtils extends Object
Utilities for working with PersistentDataContainers.
  • Constructor Details

    • PDCUtils

      public PDCUtils()
  • Method Details

    • getPersistentDataContainer

      public static io.papermc.paper.persistence.PersistentDataContainerView getPersistentDataContainer(Object holder)
      Gets the data container of an object. Use editPersistentDataContainer(Object, Consumer) if editing is desired.
      Parameters:
      holder - Source of the container
      Returns:
      The container, or null if the holder doesn't have one.
    • getPersistentDataContainer

      public static io.papermc.paper.persistence.PersistentDataContainerView getPersistentDataContainer(Object holder, Consumer<io.papermc.paper.persistence.PersistentDataContainerView> consumer)
      Gets the data container of an object. Use editPersistentDataContainer(Object, Consumer) if editing is desired.
      Parameters:
      holder - Source of the container
      consumer - Code to run with the container
      Returns:
      The container, or null if the holder doesn't have one.
    • editPersistentDataContainer

      public static void editPersistentDataContainer(Object holder, Consumer<org.bukkit.persistence.PersistentDataContainer> consumer)
      Helper to easily edit PDCs.
      Parameters:
      holder - The holder of the PDC.
      consumer - The method to run to edit the PDC.