Package dev.crafty.core.player
Class CooldownManager
java.lang.Object
dev.crafty.core.player.CooldownManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
createCooldown
(String key, long cooldownMs) Creates a cooldown with the specified key and duration.static boolean
tryPerformAction
(String key, UUID playerId, Runnable action) Attempts to perform an action if the player is not on cooldown.
-
Constructor Details
-
CooldownManager
public CooldownManager()
-
-
Method Details
-
createCooldown
Creates a cooldown with the specified key and duration.- Parameters:
key
- The cooldown key identifiercooldownMs
- The cooldown duration in milliseconds
-
tryPerformAction
Attempts to perform an action if the player is not on cooldown. If the cooldown has expired or doesn't exist, the action is executed and the cooldown is updated.- Parameters:
key
- The cooldown key to checkplayerId
- The UUID of the playeraction
- The action to perform if not on cooldown- Returns:
- true if the action was performed, false if blocked by cooldown
-