From d31ff5553ef4c3b3b832673110647d406d365771 Mon Sep 17 00:00:00 2001 From: Zarkrey <63103822+Zarkreyy@users.noreply.github.com> Date: Sun, 1 Dec 2024 00:56:54 +0100 Subject: [PATCH] Remove extraneous code in command preprocess event handling --- .../essentials/EssentialsPlayerListener.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java index 1c40363d2..e6b5043e0 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java @@ -65,7 +65,6 @@ import java.lang.management.ManagementFactory; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -705,21 +704,17 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor { // If so, no need to check for (and write) new ones. boolean cooldownFound = false; - // Iterate over a copy of getCommandCooldowns in case of concurrent modifications - for (final Entry entry : new HashMap<>(user.getCommandCooldowns()).entrySet()) { + for (final Entry entry : user.getCommandCooldowns().entrySet()) { // Remove any expired cooldowns if (entry.getValue() <= System.currentTimeMillis()) { user.clearCommandCooldown(entry.getKey()); // Don't break in case there are other command cooldowns left to clear. } else if (entry.getKey().matcher(fullCommand).matches()) { // User's current cooldown hasn't expired, inform and terminate cooldown code. - if (entry.getValue() > System.currentTimeMillis()) { - final String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue()); - user.sendTl("commandCooldown", commandCooldownTime); - cooldownFound = true; - event.setCancelled(true); - break; - } + final String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue()); + user.sendTl("commandCooldown", commandCooldownTime); + cooldownFound = true; + event.setCancelled(true); } }