public interface Cooldown extends GsonSerializable
| Modifier and Type | Method and Description |
|---|---|
Cooldown |
copy()
Copies the properties of this cooldown to a new instance
|
static Cooldown |
deserialize(com.google.gson.JsonElement element) |
default long |
elapsed()
Returns the elapsed time in milliseconds since the cooldown was last reset, or since creation time
|
OptionalLong |
getLastTested()
Return the time in milliseconds when this cooldown was last
test()ed. |
long |
getTimeout()
Gets the timeout in milliseconds for this cooldown
|
static Cooldown |
of(long amount,
TimeUnit unit)
Creates a cooldown lasting a specified amount of time
|
static Cooldown |
ofTicks(long ticks)
Creates a cooldown lasting a number of game ticks
|
default long |
remainingMillis()
Gets the time in milliseconds until the cooldown will become inactive.
|
default long |
remainingTime(TimeUnit unit)
Gets the time until the cooldown will become inactive.
|
default void |
reset()
Resets the cooldown
|
void |
setLastTested(long time)
Sets the time in milliseconds when this cooldown was last tested.
|
default boolean |
test()
Returns true if the cooldown is not active, and then resets the timer
|
default boolean |
testSilently()
Returns true if the cooldown is not active
|
deserialize, deserializeRaw, getDeserializeMethod, serializestatic Cooldown deserialize(com.google.gson.JsonElement element)
@Nonnull static Cooldown ofTicks(long ticks)
ticks - the number of ticks@Nonnull static Cooldown of(long amount, @Nonnull TimeUnit unit)
amount - the amount of timeunit - the unit of timedefault boolean test()
If the cooldown is currently active, the timer is not reset.
default boolean testSilently()
default long elapsed()
default void reset()
default long remainingMillis()
If the cooldown is not active, this method returns 0.
default long remainingTime(TimeUnit unit)
If the cooldown is not active, this method returns 0.
unit - the unit to return in@Nonnull OptionalLong getLastTested()
test()ed.void setLastTested(long time)
Note: this should only be used when re-constructing a cooldown
instance. Use test() otherwise.
time - the timelong getTimeout()
Copyright © 2020. All rights reserved.