Package com.winterhavenmc.library.messagebuilder.pipeline.cooldown


package com.winterhavenmc.library.messagebuilder.pipeline.cooldown
Provides support for message rate limiting through a cooldown mechanism.

This package is responsible for ensuring that certain messages—typically those tied to player actions such as block interactions—are not shown too frequently. This helps prevent message spam when a player holds down a mouse button or repeatedly triggers the same event.

The Cooldown interface defines the contract for determining whether a message is currently cooling down. The concrete CooldownMap implementation manages expiration timestamps for messages on a per-recipient basis.

Design and Behavior

  • Cooldowns are keyed by a CooldownKey, which typically includes both the player's UUID and the MessageId.
  • Message delay durations are defined in the message YAML file under each message entry, giving server operators full control over cooldown durations per message.
  • The putExpirationTime method sets a cooldown for a specific message and player.
  • The notCooling method returns true if the cooldown has expired or was never set, meaning the message may be shown again.
  • The removeExpired() method removes expired cooldowns from memory, which may be useful in long-running servers or diagnostic tooling.

Typical Use Case

Used by the MessageSender and TitleSender implementations in the sender package to throttle message frequency, especially in cases where user interaction may trigger rapid repeated events.
  • Class
    Description
    A functional interface representing a cooldown check for a given key.
    An implementation of a key for use in the cooldown map.
    An implementation of Cooldown that maintains a per-message cooldown map.