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 Summary
ConstructorsConstructorDescriptionCustomUseCooldownComponent
(float cooldownSeconds, org.bukkit.NamespacedKey cooldownGroup) Constructs a new CustomUseCooldownComponent with the specified cooldown time and group. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.NamespacedKey
Gets the cooldown group represented by aNamespacedKey
.float
Gets the cooldown time in seconds.Serializes this cooldown component into a map for data storage.void
setCooldownGroup
(@Nullable org.bukkit.NamespacedKey cooldownGroup) Sets the cooldown group.void
setCooldownSeconds
(float cooldownSeconds) Sets the cooldown time in seconds.
-
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 secondscooldownGroup
- theNamespacedKey
representing the cooldown group
-
-
Method Details
-
getCooldownSeconds
public float getCooldownSeconds()Gets the cooldown time in seconds.- Specified by:
getCooldownSeconds
in interfaceorg.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 interfaceorg.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 aNamespacedKey
.- Specified by:
getCooldownGroup
in interfaceorg.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 interfaceorg.bukkit.inventory.meta.components.UseCooldownComponent
- Parameters:
cooldownGroup
- theNamespacedKey
representing the cooldown group, or null to remove the group
-
serialize
Serializes this cooldown component into a map for data storage.- Specified by:
serialize
in interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable
- Returns:
- a map containing the cooldown group and its corresponding cooldown time
-