-
Notifications
You must be signed in to change notification settings - Fork 0
H | Utility: CooldownUtils
CooldownUtils helps you manage ability cooldowns for players. Every function is documented with usage and examples.
What it does:
Sets a cooldown for the given player and key (e.g., the name of the ability/item).
Example:
CooldownUtils.setCooldown(player.getUniqueId(), "FireballAbility", 10);Sets a 10-second cooldown for "FireballAbility" for this player.
What it does:
Checks whether the cooldown is still active for the given player/key.
Example:
if (CooldownUtils.isOnCooldown(player.getUniqueId(), "FireballAbility")) {
// Block ability use
}What it does:
Returns the number of seconds left on the cooldown. If not on cooldown, returns 0 or negative.
Example:
double secondsLeft = CooldownUtils.getRemainingCooldown(player.getUniqueId(), "FireballAbility");
if (secondsLeft > 0) {
player.sendMessage("Wait " + secondsLeft + " seconds!");
}What it does:
Sends a formatted message to the player about how many seconds are left.
Example:
CooldownUtils.sendCooldownMessage(player, "FireballAbility", CooldownUtils.getRemainingCooldown(player.getUniqueId(), "FireballAbility"));Displays a message like: “FireballAbility is on cooldown for 7.2 more seconds!”
What it does:
Removes all cooldowns for a single player.
Example:
CooldownUtils.clearCooldowns(player);What it does:
Removes all cooldowns for all players.
Example:
CooldownUtils.clearAllCooldowns();What it does:
Saves or loads all cooldown data to/from a file.
Example:
CooldownUtils.saveCooldowns(new File(plugin.getDataFolder(), "cooldowns.dat"));
CooldownUtils.loadCooldowns(new File(plugin.getDataFolder(), "cooldowns.dat"));- Use cooldowns to restrict how often an item/ability can be used.
- Store the key as
"AbilityName","ItemName", etc. for clarity. - Always call
isOnCooldownbefore triggering an ability. - Optionally, call
sendCooldownMessageto provide user feedback.
- Home
- A | Getting Started & Plugin Overview
- B | The Registry System: Items, Foods, Commands, Events
- C | Creating Custom Items
- D | Creating Custom Foods
- E | Advanced: Custom Effects in FXItems
- F | Creating Custom Commands
- G | Creating Custom Events & Behaviors
- H | Utility: CooldownUtils
- I | Utility: CustomItemUtils
- J | Utility: EffectUtils
- K | Utility: ManaUtils
- L | Utility: OneTimeCraftUtils
- M | Utility: TeleportUtils
- N | Utility: ProjectileUtils
- O | Utility: GammaUtils
- P | Utility: EntitySizeUtils
- Q | FXItems API (com.noctify.API) & Making Addons
- R | Advanced Techniques, Gotchas & FAQ
- S | Auto-Registration System
- T | Migration Guide (v1.1 → v1.2+)
- U | Changelog