Class CooldownManager
java.lang.Object
org.skriptlang.skript.bukkit.command.custom.CooldownManager
Used to manage cooldowns for an individual command.
-
Constructor Summary
ConstructorsConstructorDescriptionCooldownManager(Timespan cooldown, @Nullable Expression<? extends net.kyori.adventure.text.Component> cooldownMessage, @Nullable String cooldownBypass, @Nullable VariableString cooldownStorage, RuntimeErrorProducer errorProducer) -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckExecution(org.bukkit.event.Event event, org.bukkit.command.CommandSender commandSender) Checks whethersenderhas an active cooldown.@Nullable String@Nullable DategetStartDate(org.bukkit.event.Event context, org.bukkit.command.CommandSender sender) Obtains the start date ofsender's most recent cooldown.voidsetStartDate(org.bukkit.event.Event context, org.bukkit.command.CommandSender sender, @Nullable Date startDate) Sets the start date ofsender's cooldown.
-
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
- Returns:
- The cooldown this manager uses.
-
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 ofsender'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 ofsender'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 whethersenderhas an active cooldown. If they do not, this method sets a new cooldown and returnstrue.- Parameters:
event- Event providing context.commandSender- The sender to check.- Returns:
- Whether command execution can proceed.
-