Interface CooldownHandler<S extends Source>

Type Parameters:
S - the sender-valueType

@AvailableSince("1.0.0") public interface CooldownHandler<S extends Source>
Cool-down checker and handler for the command usages CommandUsage
  • Method Details

    • registerExecutionMoment

      void registerExecutionMoment(S source)
      Sets the last time of execution to this current moment using System.currentTimeMillis()
      Parameters:
      source - the command sender executing the CommandUsage
    • getUsageCooldown

      Optional<UsageCooldown> getUsageCooldown()
      The required of a usage
      Returns:
      the container of usage's cooldown, the container may be empty
    • hasCooldown

      default boolean hasCooldown(S source)
      Checks if there's a cooldown on the usage for a specific command sender
      Parameters:
      source - the command sender/source
      Returns:
      whether there's a current cooldown on the usage for the command sender
    • removeCooldown

      void removeCooldown(S source)
      Unregisters the user's cached cooldown when it's expired!
      Parameters:
      source - the command-sender
    • getLastTimeExecuted

      Optional<Instant> getLastTimeExecuted(S source)
      Fetches the last time the command source executed a specific command usage
      Parameters:
      source - the command sender
      Returns:
      the last time the sender executed CommandUsage
    • createDefault

      static <S extends Source> CooldownHandler<S> createDefault(CommandUsage<S> usage)