From 7f5f6b6ac9a8b6c9ba6986d61a8c502e85f8c8ee Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 22 May 2012 21:02:28 +0100 Subject: [PATCH] Tidy up PVP attack delay. --- .../earth2me/essentials/EssentialsEntityListener.java | 10 +++++----- Essentials/src/com/earth2me/essentials/Settings.java | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java index 2f92cfd52..9b11f0a24 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEntityListener.java @@ -32,18 +32,18 @@ public class EssentialsEntityListener implements Listener { final User defender = ess.getUser(eDefend); final User attacker = ess.getUser(eAttack); - - if (!attacker.isAuthorized("essentials.pvpdelay.exempt") && - System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())) + + if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt") + && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay()))) { event.setCancelled(true); } - + if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport()) { event.setCancelled(true); } - + attacker.updateActivity(true); final List commandList = attacker.getPowertool(attacker.getItemInHand()); if (commandList != null && !commandList.isEmpty()) diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index bcb19c380..b1352b6c3 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -388,6 +388,7 @@ public class Settings implements ISettings cancelAfkOnMove = _cancelAfkOnMove(); getFreezeAfkPlayers = _getFreezeAfkPlayers(); itemSpawnBl = _getItemSpawnBlacklist(); + loginAttackDelay = _loginAttackDelay(); kits = _getKits(); chatFormats.clear(); } @@ -805,6 +806,8 @@ public class Settings implements ISettings return teleportInvulnerability; } + private long loginAttackDelay; + private long _loginAttackDelay() { return config.getLong("login-attack-delay", 0) * 1000; @@ -813,7 +816,7 @@ public class Settings implements ISettings @Override public long getLoginAttackDelay() { - return _loginAttackDelay(); + return loginAttackDelay; } }