Class ServerCooldownManager
java.lang.Object
dev.bouncingelf10.timelesslib.api.cooldown.ServerCooldownManager
Tracks per-player cooldowns on the server, keyed by owner UUID and a namespaced key.
Obtain the shared instance through
Obtain the shared instance through
TimelessLib.cooldowns() - this class cannot be constructed by other mods.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionServerCooldownManager(InternalAccess access, ServerCountdownManager countdowns) -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if a cooldown is ready for the given owner and key.
Note: "Ready" means that the cooldown has finished (or was never started).protected CooldownnewCooldown(Duration duration, Duration tickInterval, TimeSource timeSource, Runnable onFinishCleanup) Constructs the underlying countdown-backed cooldown.protected UUIDnormalizeOwner(UUID owner) voidCancels the cooldown for the given owner and key, making it immediately ready.voidYou should probably usereset(UUID, Identifier)instead.Starts a cooldown for the given owner.startIfAbsent(UUID owner, net.minecraft.resources.Identifier key, Duration duration, TimeSource timeSource) Starts a cooldown for the given owner if it does not exist yet.startRealtime(UUID owner, net.minecraft.resources.Identifier key, Duration duration) Starts a realtime cooldown for the given owner.
-
Constructor Details
-
ServerCooldownManager
-
-
Method Details
-
normalizeOwner
-
newCooldown
protected Cooldown newCooldown(Duration duration, Duration tickInterval, TimeSource timeSource, Runnable onFinishCleanup) Constructs the underlying countdown-backed cooldown. Implementations must invokeonFinishCleanupexactly once, whether the cooldown expires naturally orCooldown.reset()is called early - this is what keeps the owner/key bookkeeping in sync (seereset(UUID, Identifier)). -
start
-
startRealtime
-
startIfAbsent
public Cooldown startIfAbsent(UUID owner, net.minecraft.resources.Identifier key, Duration duration, TimeSource timeSource) Starts a cooldown for the given owner if it does not exist yet. If it does exist, it is returned instead.- Parameters:
owner- Owner of the cooldown.key- Cooldown key.duration- Cooldown duration.timeSource- Time source to use for the cooldown.- Returns:
Cooldown- See Also:
-
isReady
Checks if a cooldown is ready for the given owner and key.
Note: "Ready" means that the cooldown has finished (or was never started).- Parameters:
owner- Owner of the cooldown.key- Cooldown key.- Returns:
- true if the cooldown is ready, false otherwise.
-
remaining
-
reset
Cancels the cooldown for the given owner and key, making it immediately ready.
This is the one true cancellation path - it always keeps the owner/key bookkeeping in sync, whether called directly or viaCooldown.reset(). -
resetAll
You should probably usereset(UUID, Identifier)instead. Especially if you're NOT using a custom key scheme.
-