| Modifier and Type | Method and Description |
|---|---|
void |
cooldown()
Starts the cooldown with the duration specified in
@Cooldown. |
void |
cooldown(@Range(from=1L,to=9223372036854775807L) long duration,
@NotNull java.util.concurrent.TimeUnit unit)
Starts the cooldown for a specific duration.
|
default long |
elapsed(@NotNull java.util.concurrent.TimeUnit outputUnit)
Returns the elapsed cooldown time in the specified time unit.
|
long |
elapsedMillis()
Returns the elapsed time since the cooldown started in milliseconds.
|
boolean |
isOnCooldown()
Checks if the cooldown is currently active.
|
default long |
remainingTime(long cooldownValue,
@NotNull java.util.concurrent.TimeUnit cooldownUnit)
Calculates the remaining cooldown time in the same unit as the cooldown.
|
default long |
remainingTime(long cooldownValue,
@NotNull java.util.concurrent.TimeUnit cooldownUnit,
@NotNull java.util.concurrent.TimeUnit outputUnit)
Calculates the remaining cooldown time in a specified output unit.
|
long |
remainingTime(@NotNull java.util.concurrent.TimeUnit outputUnit)
Gets the remaining cooldown time in the specified unit.
|
long |
remainingTimeMillis()
Gets the remaining cooldown time in milliseconds.
|
default long |
remainingTimeMillis(long cooldownValue,
@NotNull java.util.concurrent.TimeUnit cooldownUnit)
Calculates the remaining time for a specific cooldown in milliseconds.
|
void |
removeCooldown()
Removes the active cooldown immediately.
|
void |
requireNotOnCooldown()
Throws an exception if currently on cooldown.
|
void |
requireNotOnCooldown(long cooldownValue,
@NotNull java.util.concurrent.TimeUnit cooldownUnit)
Throws an exception if on cooldown based on the specified duration.
|
@NotNull CooldownHandle |
withCooldown(long cooldownValue,
@NotNull java.util.concurrent.TimeUnit unit)
Creates a new
CooldownHandle that is identical to this handle,
except that it has a specified cooldown value and unit. |
@CheckReturnValue
@Contract(pure=true,
value="_, _ -> new")
@NotNull
@NotNull CooldownHandle withCooldown(long cooldownValue,
@NotNull
@NotNull java.util.concurrent.TimeUnit unit)
CooldownHandle that is identical to this handle,
except that it has a specified cooldown value and unit.
This handle allows calling shortcut methods such as cooldown(),
remainingTimeMillis(), etc.
cooldownValue - Cooldown valueunit - The time unit of the cooldownCooldownHandleboolean isOnCooldown()
true if on cooldown, false otherwise.long elapsedMillis()
If the user is not on cooldown, this will return zero.
void cooldown()
@Cooldown.java.lang.IllegalArgumentException - if the CooldownHandle parameter does not
have @Cooldown on itvoid requireNotOnCooldown()
throws CooldownException
CooldownException - if on cooldown.java.lang.IllegalArgumentException - if the CooldownHandle parameter does not
have @Cooldown on itvoid requireNotOnCooldown(long cooldownValue,
@NotNull
@NotNull java.util.concurrent.TimeUnit cooldownUnit)
throws CooldownException
cooldownValue - Cooldown duration.cooldownUnit - Time unit for the cooldown duration.CooldownException - if on cooldown.void removeCooldown()
default long elapsed(@NotNull
@NotNull java.util.concurrent.TimeUnit outputUnit)
outputUnit - Time unit for the result.void cooldown(@Range(from=1L,to=9223372036854775807L) long duration,
@NotNull
@NotNull java.util.concurrent.TimeUnit unit)
duration - Cooldown duration.unit - Time unit for the duration.long remainingTimeMillis()
java.lang.IllegalArgumentException - if the CooldownHandle parameter does not
have @Cooldown on itlong remainingTime(@NotNull
@NotNull java.util.concurrent.TimeUnit outputUnit)
outputUnit - Time unit for the result.java.lang.IllegalArgumentException - if the CooldownHandle parameter does not
have @Cooldown on itdefault long remainingTimeMillis(long cooldownValue,
@NotNull
@NotNull java.util.concurrent.TimeUnit cooldownUnit)
cooldownValue - Cooldown duration.cooldownUnit - Time unit for the duration.default long remainingTime(long cooldownValue,
@NotNull
@NotNull java.util.concurrent.TimeUnit cooldownUnit)
cooldownValue - Cooldown duration.cooldownUnit - Time unit for the cooldown.default long remainingTime(long cooldownValue,
@NotNull
@NotNull java.util.concurrent.TimeUnit cooldownUnit,
@NotNull
@NotNull java.util.concurrent.TimeUnit outputUnit)
cooldownValue - Cooldown duration.cooldownUnit - Time unit for the cooldown.outputUnit - Desired time unit for the result.