Class CustomUseCooldownComponent

java.lang.Object
io.github.lucfr1746.llibrary.itemstack.component.CustomUseCooldownComponent
All Implemented Interfaces:
org.bukkit.configuration.serialization.ConfigurationSerializable, org.bukkit.inventory.meta.components.UseCooldownComponent

public class CustomUseCooldownComponent extends Object implements org.bukkit.inventory.meta.components.UseCooldownComponent
Represents a custom implementation of the UseCooldownComponent interface. This class allows defining a custom cooldown for item usage, specifying the cooldown time and the group it belongs to.
  • Constructor Details

    • CustomUseCooldownComponent

      public CustomUseCooldownComponent(float cooldownSeconds, org.bukkit.NamespacedKey cooldownGroup)
      Constructs a new CustomUseCooldownComponent with the specified cooldown time and group.
      Parameters:
      cooldownSeconds - the cooldown duration in seconds
      cooldownGroup - the NamespacedKey representing the cooldown group
  • Method Details

    • getCooldownSeconds

      public float getCooldownSeconds()
      Gets the cooldown time in seconds.
      Specified by:
      getCooldownSeconds in interface org.bukkit.inventory.meta.components.UseCooldownComponent
      Returns:
      the cooldown duration in seconds
    • setCooldownSeconds

      public void setCooldownSeconds(float cooldownSeconds)
      Sets the cooldown time in seconds.
      Specified by:
      setCooldownSeconds in interface org.bukkit.inventory.meta.components.UseCooldownComponent
      Parameters:
      cooldownSeconds - the new cooldown duration in seconds
    • getCooldownGroup

      @Nullable public @Nullable org.bukkit.NamespacedKey getCooldownGroup()
      Gets the cooldown group represented by a NamespacedKey.
      Specified by:
      getCooldownGroup in interface org.bukkit.inventory.meta.components.UseCooldownComponent
      Returns:
      the cooldown group, or null if not set
    • setCooldownGroup

      public void setCooldownGroup(@Nullable @Nullable org.bukkit.NamespacedKey cooldownGroup)
      Sets the cooldown group.
      Specified by:
      setCooldownGroup in interface org.bukkit.inventory.meta.components.UseCooldownComponent
      Parameters:
      cooldownGroup - the NamespacedKey representing the cooldown group, or null to remove the group
    • serialize

      @NotNull public @NotNull Map<String,Object> serialize()
      Serializes this cooldown component into a map for data storage.
      Specified by:
      serialize in interface org.bukkit.configuration.serialization.ConfigurationSerializable
      Returns:
      a map containing the cooldown group and its corresponding cooldown time