mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-05 07:57:59 +01:00
Remove extraneous code in command preprocess event handling
This commit is contained in:
parent
b560bbdec4
commit
d31ff5553e
@ -65,7 +65,6 @@ import java.lang.management.ManagementFactory;
|
|||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
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.
|
// If so, no need to check for (and write) new ones.
|
||||||
boolean cooldownFound = false;
|
boolean cooldownFound = false;
|
||||||
|
|
||||||
// Iterate over a copy of getCommandCooldowns in case of concurrent modifications
|
for (final Entry<Pattern, Long> entry : user.getCommandCooldowns().entrySet()) {
|
||||||
for (final Entry<Pattern, Long> entry : new HashMap<>(user.getCommandCooldowns()).entrySet()) {
|
|
||||||
// Remove any expired cooldowns
|
// Remove any expired cooldowns
|
||||||
if (entry.getValue() <= System.currentTimeMillis()) {
|
if (entry.getValue() <= System.currentTimeMillis()) {
|
||||||
user.clearCommandCooldown(entry.getKey());
|
user.clearCommandCooldown(entry.getKey());
|
||||||
// Don't break in case there are other command cooldowns left to clear.
|
// Don't break in case there are other command cooldowns left to clear.
|
||||||
} else if (entry.getKey().matcher(fullCommand).matches()) {
|
} else if (entry.getKey().matcher(fullCommand).matches()) {
|
||||||
// User's current cooldown hasn't expired, inform and terminate cooldown code.
|
// User's current cooldown hasn't expired, inform and terminate cooldown code.
|
||||||
if (entry.getValue() > System.currentTimeMillis()) {
|
|
||||||
final String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue());
|
final String commandCooldownTime = DateUtil.formatDateDiff(entry.getValue());
|
||||||
user.sendTl("commandCooldown", commandCooldownTime);
|
user.sendTl("commandCooldown", commandCooldownTime);
|
||||||
cooldownFound = true;
|
cooldownFound = true;
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user