Class Cooldown

java.lang.Object
net.minestom.server.utils.time.Cooldown

public final class Cooldown extends Object
  • Constructor Details

    • Cooldown

      public Cooldown(Duration duration)
  • Method Details

    • getDuration

      public Duration getDuration()
    • refreshLastUpdate

      public void refreshLastUpdate(long lastUpdate)
    • isReady

      public boolean isReady(long time)
    • hasCooldown

      public static boolean hasCooldown(long currentTime, long lastUpdate, @NotNull @NotNull TemporalUnit temporalUnit, long cooldown)
      Gets if something is in cooldown based on the current time.
      Parameters:
      currentTime - the current time in milliseconds
      lastUpdate - the last update in milliseconds
      temporalUnit - the time unit of the cooldown
      cooldown - the value of the cooldown
      Returns:
      true if the cooldown is in progress, false otherwise
    • hasCooldown

      public static boolean hasCooldown(long currentTime, long lastUpdate, @NotNull @NotNull Duration duration)
      Gets if something is in cooldown based on the current time.
      Parameters:
      currentTime - the current time in milliseconds
      lastUpdate - the last update in milliseconds
      duration - the cooldown
      Returns:
      true if the cooldown is in progress, false otherwise
    • hasCooldown

      public static boolean hasCooldown(long lastUpdate, @NotNull @NotNull TemporalUnit temporalUnit, int cooldown)
      Gets if something is in cooldown based on the current time (System.currentTimeMillis()).
      Parameters:
      lastUpdate - the last update in milliseconds
      temporalUnit - the time unit of the cooldown
      cooldown - the value of the cooldown
      Returns:
      true if the cooldown is in progress, false otherwise