Interface CooldownRepository


public interface CooldownRepository
Stores when each player's cooldowns run out. Entries live in memory and are mirrored to the other servers so a cooldown cannot be dodged by switching server.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final record 
    Identifies one cooldown by a player and the thing they are waiting on.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    getTimeLeft(UUID playerUUID, Cooldown cooldown, String cooldownOwner)
    How long a player must still wait, starting a new window when the old one has run out.
    void
    syncProxy(UUID playerUUID, String cooldownOwner, long newExpireTime)
    Tells the other servers about a cooldown that just started here.
    boolean
    updateCache(UUID playerUUID, String cooldownClass, long newExpireTime)
    Records an expiry time that arrived from another server.
  • Method Details

    • getTimeLeft

      long getTimeLeft(UUID playerUUID, Cooldown cooldown, String cooldownOwner)
      How long a player must still wait, starting a new window when the old one has run out.
      Parameters:
      playerUUID - the player
      cooldown - the cooldown settings
      cooldownOwner - what the cooldown applies to
      Returns:
      the remaining milliseconds, or 0 if the player may act now
    • updateCache

      boolean updateCache(UUID playerUUID, String cooldownClass, long newExpireTime)
      Records an expiry time that arrived from another server.
      Parameters:
      playerUUID - the player
      cooldownClass - what the cooldown applies to
      newExpireTime - when it runs out, in milliseconds
      Returns:
      true if the stored value changed
    • syncProxy

      void syncProxy(UUID playerUUID, String cooldownOwner, long newExpireTime)
      Tells the other servers about a cooldown that just started here.
      Parameters:
      playerUUID - the player
      cooldownOwner - what the cooldown applies to
      newExpireTime - when it runs out, in milliseconds