Skip to content

Commit

Permalink
11.0.0.0: (CheatPrevention) Fixed blocked command message not showing…
Browse files Browse the repository at this point in the history
… up sometimes.
  • Loading branch information
SirBlobman committed May 27, 2021
1 parent b67dd10 commit d6c168a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d6c168a

Please sign in to comment.