Class AbstractCooldownManager<T>

java.lang.Object
dev.bouncingelf10.timelesslib.api.countdown.CountdownManager<T>
dev.bouncingelf10.timelesslib.api.cooldown.AbstractCooldownManager<T>
Direct Known Subclasses:
ClientCooldownManager, ServerCooldownManager

public abstract class AbstractCooldownManager<T> extends CountdownManager<T>
  • Constructor Details

    • AbstractCooldownManager

      protected AbstractCooldownManager(Supplier<T> context)
    • AbstractCooldownManager

      protected AbstractCooldownManager(Supplier<T> context, int poolSize)
  • Method Details

    • normalizeOwner

      protected abstract UUID normalizeOwner(UUID owner)
    • start

      public Countdown start(UUID owner, String key, Duration duration)
      Starts a cooldown for the given owner.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      duration - Cooldown duration.
      Returns:
      Countdown
      See Also:
    • startRealtime

      public Countdown startRealtime(UUID owner, String key, Duration duration)
      Starts a realtime cooldown for the given owner.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      duration - Cooldown duration.
      Returns:
      Countdown
      See Also:
    • startIfAbsent

      public Countdown startIfAbsent(UUID owner, String key, Duration duration, TimeSource timeSource)
      Starts a cooldown for the given owner if it does not exist yet. If it does exist, it is returned instead.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      duration - Cooldown duration.
      timeSource - Time source to use for the cooldown.
      Returns:
      Countdown
      See Also:
    • isReady

      public boolean isReady(UUID owner, String key)
      Checks if a cooldown is ready for the given owner and key.
      Note: "Ready" means that the cooldown has finished.
      Parameters:
      owner - Owner of the cooldown.
      key - Cooldown key.
      Returns:
      true if the cooldown is ready, false otherwise.
    • remaining

      public Duration remaining(UUID owner, String key)
    • reset

      public void reset(UUID owner, String key)
    • resetAll

      public void resetAll(UUID owner)
      You should probably use reset(UUID, String) instead. Especially if you're NOT using a custom CooldownManager.