Class CooldownManager

java.lang.Object
org.skriptlang.skript.bukkit.command.custom.CooldownManager

public class CooldownManager extends Object
Used to manage cooldowns for an individual command.
  • Constructor Details

    • CooldownManager

      public CooldownManager(Timespan cooldown, @Nullable @Nullable Expression<? extends net.kyori.adventure.text.Component> cooldownMessage, @Nullable @Nullable String cooldownBypass, @Nullable @Nullable VariableString cooldownStorage, RuntimeErrorProducer errorProducer)
  • Method Details

    • getCooldown

      public Timespan getCooldown()
      Returns:
      The cooldown this manager uses.
    • getCooldownBypass

      @Nullable public @Nullable String getCooldownBypass()
      Returns:
      A permission, if set, to bypass this manager's cooldown.
    • getStartDate

      @Nullable public @Nullable Date getStartDate(org.bukkit.event.Event context, org.bukkit.command.CommandSender sender)
      Obtains the start date of sender's most recent cooldown.
      Parameters:
      context - Event providing context.
      sender - The sender to obtain the cooldown for.
      Returns:
      The start date of sender's cooldown, or null if no cooldown is set. Note that this may return a value even if the cooldown is expired.
    • setStartDate

      public void setStartDate(org.bukkit.event.Event context, org.bukkit.command.CommandSender sender, @Nullable @Nullable Date startDate)
      Sets the start date of sender's cooldown.
      Parameters:
      context - Event providing context.
      sender - The sender to set the cooldown for.
      startDate - New cooldown start date, or null to remove any cooldown.
    • checkExecution

      public boolean checkExecution(org.bukkit.event.Event event, org.bukkit.command.CommandSender commandSender)
      Checks whether sender has an active cooldown. If they do not, this method sets a new cooldown and returns true.
      Parameters:
      event - Event providing context.
      commandSender - The sender to check.
      Returns:
      Whether command execution can proceed.