From d6c168afa7e6536c795eaf92c2cc2ff5d798e00b Mon Sep 17 00:00:00 2001 From: SirBlobman Date: Thu, 27 May 2021 17:48:44 -0400 Subject: [PATCH] 11.0.0.0: (CheatPrevention) Fixed blocked command message not showing up sometimes. --- .../cheat/prevention/listener/ListenerCommands.java | 4 ++-- .../prevention/listener/CheatPreventionListener.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/expansion/cheat-prevention/expansion/src/main/java/combatlogx/expansion/cheat/prevention/listener/ListenerCommands.java b/expansion/cheat-prevention/expansion/src/main/java/combatlogx/expansion/cheat/prevention/listener/ListenerCommands.java index 9d102be18..9e7904bfd 100644 --- a/expansion/cheat-prevention/expansion/src/main/java/combatlogx/expansion/cheat/prevention/listener/ListenerCommands.java +++ b/expansion/cheat-prevention/expansion/src/main/java/combatlogx/expansion/cheat/prevention/listener/ListenerCommands.java @@ -131,6 +131,6 @@ private void checkEvent(PlayerCommandPreprocessEvent e) { e.setCancelled(true); Replacer replacer = message -> message.replace("{command}", realCommand); - sendMessage(player, "expansion.cheat-prevention.command-blocked", replacer); + sendMessageIgnoreCooldown(player, "expansion.cheat-prevention.command-blocked", replacer); } -} \ No newline at end of file +} diff --git a/expansion/cheat-prevention/legacy/src/main/java/combatlogx/expansion/cheat/prevention/listener/CheatPreventionListener.java b/expansion/cheat-prevention/legacy/src/main/java/combatlogx/expansion/cheat/prevention/listener/CheatPreventionListener.java index 4aab83680..1fd3653f4 100644 --- a/expansion/cheat-prevention/legacy/src/main/java/combatlogx/expansion/cheat/prevention/listener/CheatPreventionListener.java +++ b/expansion/cheat-prevention/legacy/src/main/java/combatlogx/expansion/cheat/prevention/listener/CheatPreventionListener.java @@ -20,14 +20,18 @@ public CheatPreventionListener(Expansion expansion) { this.messageCooldownMap = new HashMap<>(); } + protected final void sendMessageIgnoreCooldown(Player player, String key, Replacer replacer) { + LanguageManager languageManager = getLanguageManager(); + languageManager.sendMessage(player, key, replacer, true); + addMessageCooldown(player, key); + } + protected final void sendMessage(Player player, String key, Replacer replacer) { long systemMillis = System.currentTimeMillis(); long expireMillis = getCooldownExpireTime(player, key); - if(expireMillis < systemMillis) return; + if(systemMillis < expireMillis) return; - LanguageManager languageManager = getLanguageManager(); - languageManager.sendMessage(player, key, replacer, true); - addMessageCooldown(player, key); + sendMessageIgnoreCooldown(player, key, replacer); } private long getNewMessageCooldownExpireTime() {