PlayerAttackCooldownTracker
Tracks each player's last melee-hit tick so the combat pipeline can derive melee attack charge from the real-time gap between primary swings.
This is used by the player→elite damage formula instead of Bukkit's Player.getAttackCooldown() value, which can be observed after the swing has already consumed/reset the vanilla cooldown. The captured tick gap still lets debug output distinguish properly paced swings from fast clicking.
Design
- One ConcurrentHashMap keyed by player UUID, valued by the game tick of their last hit. O(1) read/write per hit.
- Lazy initialization. The eviction sweep is only registered the first time recordHit is called — the tracker imposes zero cost on servers where no one is fighting.
- Bounded memory. A GameClock-scheduled sweep evicts UUIDs idle for more than IDLE_EVICTION_TICKS, so a player who logs out and never returns does not leak.
- No quit-listener dependency. The sweep handles cleanup, mirroring the existing pattern used by com.magmaguy.elitemobs.combatsystem.antiexploit.AutoclickerThrottle.
Properties
Functions
Link copied to clipboard
Records a melee hit from the given player and returns the number of game ticks elapsed since their previously tracked hit, or NO_PREVIOUS_HIT when this is their first recorded hit since plugin start (or since their last eviction).