Interface ICoolDownHandler<E>
- Type Parameters:
E
- The type of object that the cooldowns are assigned to. This could be any object type, commonly a player or an item.
- All Known Implementing Classes:
MilliSecCoolDownHandler
,TickCoolDownHandler
public interface ICoolDownHandler<E>
Interface for managing cooldowns of objects. This interface allows tracking and managing cooldowns for various objects,
typically used for players or items identified by unique identifiers like UUIDs.
- Since:
- 2023-04-02
- Version:
- 1.0.0
- Author:
- Maxopoly, notzune
-
Method Summary
Modifier and TypeMethodDescriptionlong
Retrieves the remaining cooldown time for the specified object.long
Returns the total maximum cooldown duration set for this handler.boolean
onCoolDown
(E e) Checks if the specified object is currently on cooldown.void
putOnCoolDown
(E e) Sets the cooldown to its maximum duration for the specified object.void
removeCooldown
(E e) Removes the cooldown for the specified object, effectively resetting its cooldown status.
-
Method Details
-
putOnCoolDown
Sets the cooldown to its maximum duration for the specified object.Usage Example:
ICoolDownHandler<Player> playerCooldownHandler = ...; playerCooldownHandler.putOnCoolDown(player);
- Parameters:
e
- The object to set the cooldown for.
-
onCoolDown
Checks if the specified object is currently on cooldown.Usage Example:
if (playerCooldownHandler.onCoolDown(player)) { System.out.println("Player is on cooldown!"); }
- Parameters:
e
- The object to check.- Returns:
- True if the object is on cooldown, false otherwise.
-
getRemainingCoolDown
Retrieves the remaining cooldown time for the specified object. The returned value is context-dependent but is always between 0 and the maximum cooldown duration.Usage Example:
long remainingTime = playerCooldownHandler.getRemainingCoolDown(player); System.out.println("Remaining cooldown time: " + remainingTime);
- Parameters:
e
- The object to get the cooldown for.- Returns:
- The remaining cooldown time for the object, or 0 if there's no active cooldown.
-
getTotalCoolDown
long getTotalCoolDown()Returns the total maximum cooldown duration set for this handler. The meaning of this duration is implementation-specific.Usage Example:
long totalCooldown = playerCooldownHandler.getTotalCoolDown(); System.out.println("Total cooldown duration: " + totalCooldown);
- Returns:
- The maximum cooldown duration for this handler.
-
removeCooldown
Removes the cooldown for the specified object, effectively resetting its cooldown status.Usage Example:
playerCooldownHandler.removeCooldown(player);
- Parameters:
e
- The object for which to remove the cooldown.
-