mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-15 11:42:47 +00:00
Add per-recipient cooldown to QuickChatExecution (#4012)
`QuickChatExecution` had no cooldown, allowing a player to spam quick-chat intents and flood a recipient's chat UI. This could bury incoming alliance request notifications, preventing them from being seen or accepted. This fix mirrors the existing emoji cooldown pattern: - Added `quickChatCooldown()` to `Config` (default: 30 ticks / 3 seconds) - Added `canSendQuickChat(recipient)` and `recordQuickChat(recipient)` to `Player` / `PlayerImpl`, tracking outgoing chats per recipient - `QuickChatExecution.tick()` now checks `canSendQuickChat` before displaying and records before the display calls (so the cooldown is always written even if display throws)
This commit is contained in:
@@ -27,8 +27,15 @@ export class QuickChatExecution implements Execution {
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (!this.sender.canSendQuickChat(this.recipient)) {
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const message = this.getMessageFromKey(this.quickChatKey);
|
||||
|
||||
this.sender.recordQuickChat(this.recipient);
|
||||
|
||||
this.mg.displayChat(
|
||||
message[1],
|
||||
message[0],
|
||||
|
||||
Reference in New Issue
Block a user