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.NamespacedKeyGets the cooldown group represented by aNamespacedKey.floatGets the cooldown time in seconds.Serializes this cooldown component into a map for data storage.voidsetCooldownGroup(@Nullable org.bukkit.NamespacedKey cooldownGroup) Sets the cooldown group.voidsetCooldownSeconds(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- theNamespacedKeyrepresenting the cooldown group
-
-
Method Details
-
getCooldownSeconds
public float getCooldownSeconds()Gets the cooldown time in seconds.- Specified by:
getCooldownSecondsin 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:
setCooldownSecondsin 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:
getCooldownGroupin 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:
setCooldownGroupin interfaceorg.bukkit.inventory.meta.components.UseCooldownComponent- Parameters:
cooldownGroup- theNamespacedKeyrepresenting the cooldown group, or null to remove the group
-
serialize
Serializes this cooldown component into a map for data storage.- Specified by:
serializein interfaceorg.bukkit.configuration.serialization.ConfigurationSerializable- Returns:
- a map containing the cooldown group and its corresponding cooldown time
-