Package net.minestom.server.utils.time
Class Cooldown
java.lang.Object
net.minestom.server.utils.time.Cooldown
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
hasCooldown
(long currentTime, long lastUpdate, @NotNull Duration duration) Gets if something is in cooldown based on the current time.static boolean
hasCooldown
(long currentTime, long lastUpdate, @NotNull TemporalUnit temporalUnit, long cooldown) Gets if something is in cooldown based on the current time.static boolean
hasCooldown
(long lastUpdate, @NotNull TemporalUnit temporalUnit, int cooldown) Gets if something is in cooldown based on the current time (System.currentTimeMillis()
).boolean
isReady
(long time) void
refreshLastUpdate
(long lastUpdate)
-
Constructor Details
-
Cooldown
-
-
Method Details
-
getDuration
-
refreshLastUpdate
public void refreshLastUpdate(long lastUpdate) -
isReady
public boolean isReady(long time) -
hasCooldown
public static boolean hasCooldown(long currentTime, long lastUpdate, @NotNull @NotNull TemporalUnit temporalUnit, long cooldown) Gets if something is in cooldown based on the current time.- Parameters:
currentTime
- the current time in millisecondslastUpdate
- the last update in millisecondstemporalUnit
- the time unit of the cooldowncooldown
- the value of the cooldown- Returns:
- true if the cooldown is in progress, false otherwise
-
hasCooldown
public static boolean hasCooldown(long currentTime, long lastUpdate, @NotNull @NotNull Duration duration) Gets if something is in cooldown based on the current time.- Parameters:
currentTime
- the current time in millisecondslastUpdate
- the last update in millisecondsduration
- the cooldown- Returns:
- true if the cooldown is in progress, false otherwise
-
hasCooldown
public static boolean hasCooldown(long lastUpdate, @NotNull @NotNull TemporalUnit temporalUnit, int cooldown) Gets if something is in cooldown based on the current time (System.currentTimeMillis()
).- Parameters:
lastUpdate
- the last update in millisecondstemporalUnit
- the time unit of the cooldowncooldown
- the value of the cooldown- Returns:
- true if the cooldown is in progress, false otherwise
-