From 9aeb49f6c3f72a50968923807315c88fb399b109 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Sat, 19 Jan 2013 15:15:43 +0000 Subject: [PATCH] Reduce chance of self repeating powertool actions. --- .../com/earth2me/essentials/EssentialsEntityListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 7e7e2763f..653068420 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -94,9 +94,10 @@ public class EssentialsEntityListener implements Listener final List commandList = attacker.getPowertool(attacker.getItemInHand()); if (commandList != null && !commandList.isEmpty()) { - for (final String command : commandList) + for (final String tempCommand : commandList) { - if (command != null && !command.isEmpty()) + final String command = tempCommand.replaceAll("\\{player\\}", defender.getName()); + if (command != null && !command.isEmpty() && !command.equals(tempCommand)) { ess.scheduleSyncDelayedTask( new Runnable() @@ -104,7 +105,7 @@ public class EssentialsEntityListener implements Listener @Override public void run() { - attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName())); + attacker.getServer().dispatchCommand(attacker.getBase(), command); LOGGER.log(Level.INFO, String.format("[PT] %s issued server command: /%s", attacker.getName(), command)); } });