Interface IKVCoolDownHandler<E,K>

Type Parameters:
E - The type of object that the cooldowns are assigned to. This could be any object type, like a player or an item.
K - The type of the key identifying different types of cooldowns, like an action or event type.
All Known Implementing Classes:
KVTickCoolDownHandler

public interface IKVCoolDownHandler<E,K>
Interface defining the contract for cooldown handlers with key-value pairs. This interface allows managing cooldowns for various actions or types, each identified by a unique key.
Since:
2023-11-13
Version:
1.0.0
Author:
Maxopoly, notzune
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets the remaining cooldown for the specified object and action.
    long
    Gets the specific cooldown duration for a given object and action.
    long
    Returns the total maximum cooldown duration for any action in this handler.
    boolean
    onCoolDown(E e, K k)
    Checks whether the given object is currently on cooldown for a specific action identified by the key.
    void
    putOnCoolDown(E e, K k)
    Puts the specified object on cooldown for a specific action identified by the key.
    void
    Removes the cooldown for the specified object and action.
  • Method Details

    • putOnCoolDown

      void putOnCoolDown(E e, K k)
      Puts the specified object on cooldown for a specific action identified by the key.

      Usage Example:

       
       IKVCoolDownHandler<Player, String> playerActionCooldown = ...;
       playerActionCooldown.putOnCoolDown(player, "jump");
       
       
      Parameters:
      e - Object to set cooldown for.
      k - Key identifying the type of cooldown.
    • onCoolDown

      boolean onCoolDown(E e, K k)
      Checks whether the given object is currently on cooldown for a specific action identified by the key.

      Usage Example:

       
       if (playerActionCooldown.onCoolDown(player, "jump")) {
           System.out.println("Player is on cooldown for jumping!");
       }
       
       
      Parameters:
      e - Object to check.
      k - Key identifying the type of cooldown.
      Returns:
      True if the object is on cooldown for the specified key, false otherwise.
    • getRemainingCoolDown

      long getRemainingCoolDown(E e, K k)
      Gets the remaining cooldown for the specified object and action. The meaning and scale (like ticks or seconds) of the returned value are dependent on the implementation. It should not be less than 0 or exceed the maximum cooldown.

      Usage Example:

       
       long remainingCooldown = playerActionCooldown.getRemainingCoolDown(player, "jump");
       System.out.println("Remaining cooldown for jumping: " + remainingCooldown);
       
       
      Parameters:
      e - Object to get cooldown for.
      k - Key identifying the type of cooldown.
      Returns:
      Remaining cooldown time for the specified action, or 0 if not on cooldown.
    • getTotalCoolDown

      long getTotalCoolDown()
      Returns the total maximum cooldown duration for any action in this handler. The meaning of this duration is specific to the implementation.

      Usage Example:

       
       long totalCooldown = playerActionCooldown.getTotalCoolDown();
       System.out.println("Total cooldown duration for any action: " + totalCooldown);
       
       
      Returns:
      The maximum cooldown duration in this handler.
    • removeCooldown

      void removeCooldown(E e, K k)
      Removes the cooldown for the specified object and action.

      Usage Example:

       
       playerActionCooldown.removeCooldown(player, "jump");
       
       
      Parameters:
      e - Object to remove cooldown for.
      k - Key identifying the type of cooldown.
    • getSpecificCoolDown

      long getSpecificCoolDown(E e, K k)
      Gets the specific cooldown duration for a given object and action. This method is useful for retrieving individual cooldown times when an object has multiple cooldowns for different actions.

      Usage Example:

       
       long actionCooldown = playerActionCooldown.getSpecificCoolDown(player, "jump");
       System.out.println("Specific cooldown for jumping: " + actionCooldown);
       
       
      Parameters:
      e - The object to get the cooldown for.
      k - The key identifying the cooldown.
      Returns:
      The specific cooldown duration for the given action, or 0 if not on cooldown.