diff options
author | KHobbits <rob@khobbits.co.uk> | 2013-02-11 23:33:30 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2013-02-11 23:33:30 +0000 |
commit | c3f0d34293fd634d7cbfc1d63ee1125ad5d5c56b (patch) | |
tree | cf160270e18710f1ed9753c057568ef5db4363c8 | |
parent | c298fb93329466b4430982a7fd7858ddbb66ae5e (diff) | |
download | Essentials-c3f0d34293fd634d7cbfc1d63ee1125ad5d5c56b.tar Essentials-c3f0d34293fd634d7cbfc1d63ee1125ad5d5c56b.tar.gz Essentials-c3f0d34293fd634d7cbfc1d63ee1125ad5d5c56b.tar.lz Essentials-c3f0d34293fd634d7cbfc1d63ee1125ad5d5c56b.tar.xz Essentials-c3f0d34293fd634d7cbfc1d63ee1125ad5d5c56b.zip |
Minor entity optimization.
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index fe7cd49f0..9714235f7 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Pattern; import org.bukkit.Material; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; @@ -18,6 +19,7 @@ public class EssentialsEntityListener implements Listener { private static final Logger LOGGER = Logger.getLogger("Minecraft"); private final IEssentials ess; + private static final transient Pattern powertoolPlayer = Pattern.compile("\\{player\\}"); public EssentialsEntityListener(IEssentials ess) { @@ -65,8 +67,9 @@ public class EssentialsEntityListener implements Listener private void onPlayerVsPlayerDamage(final EntityDamageByEntityEvent event, final Player defender, final User attacker) { - if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt") - && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay()))) + if (ess.getSettings().getLoginAttackDelay() > 0 + && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())) + && !attacker.isAuthorized("essentials.pvpdelay.exempt")) { event.setCancelled(true); } @@ -96,7 +99,7 @@ public class EssentialsEntityListener implements Listener { for (final String tempCommand : commandList) { - final String command = tempCommand.replaceAll("\\{player\\}", defender.getName()); + final String command = powertoolPlayer.matcher(tempCommand).replaceAll(defender.getName()); if (command != null && !command.isEmpty() && !command.equals(tempCommand)) { ess.scheduleSyncDelayedTask( |