Tidy up PVP attack delay.

This commit is contained in:
KHobbits 2012-05-22 21:02:28 +01:00
parent dc36a50d85
commit 7f5f6b6ac9
2 changed files with 9 additions and 6 deletions

View File

@ -32,18 +32,18 @@ public class EssentialsEntityListener implements Listener
{ {
final User defender = ess.getUser(eDefend); final User defender = ess.getUser(eDefend);
final User attacker = ess.getUser(eAttack); final User attacker = ess.getUser(eAttack);
if (!attacker.isAuthorized("essentials.pvpdelay.exempt") && if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())) && (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport()) if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
{ {
event.setCancelled(true); event.setCancelled(true);
} }
attacker.updateActivity(true); attacker.updateActivity(true);
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand()); final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty()) if (commandList != null && !commandList.isEmpty())

View File

@ -388,6 +388,7 @@ public class Settings implements ISettings
cancelAfkOnMove = _cancelAfkOnMove(); cancelAfkOnMove = _cancelAfkOnMove();
getFreezeAfkPlayers = _getFreezeAfkPlayers(); getFreezeAfkPlayers = _getFreezeAfkPlayers();
itemSpawnBl = _getItemSpawnBlacklist(); itemSpawnBl = _getItemSpawnBlacklist();
loginAttackDelay = _loginAttackDelay();
kits = _getKits(); kits = _getKits();
chatFormats.clear(); chatFormats.clear();
} }
@ -805,6 +806,8 @@ public class Settings implements ISettings
return teleportInvulnerability; return teleportInvulnerability;
} }
private long loginAttackDelay;
private long _loginAttackDelay() private long _loginAttackDelay()
{ {
return config.getLong("login-attack-delay", 0) * 1000; return config.getLong("login-attack-delay", 0) * 1000;
@ -813,7 +816,7 @@ public class Settings implements ISettings
@Override @Override
public long getLoginAttackDelay() public long getLoginAttackDelay()
{ {
return _loginAttackDelay(); return loginAttackDelay;
} }
} }