Adding new config setting login-attack-delay. Set this in seconds for a delay before players can attack each other after logging on.

Use permission "essentials.pvpdelay.exempt" to bypass this restriction
This commit is contained in:
ementalo 2012-05-22 01:29:47 +01:00
parent fa58503c9f
commit 5eeaeaee5d
4 changed files with 27 additions and 2 deletions

View File

@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.inventory.ItemStack;
@ -32,10 +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()))
{
event.setCancelled(true);
}
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
{
event.setCancelled(true);
}
attacker.updateActivity(true);
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
if (commandList != null && !commandList.isEmpty())

View File

@ -175,4 +175,6 @@ public interface ISettings extends IConf
long getTeleportInvulnerability();
boolean isTeleportInvulnerability();
long getLoginAttackDelay();
}

View File

@ -792,10 +792,22 @@ public class Settings implements ISettings
{
return (config.getLong("teleport-invulnerability", 0) > 0);
}
@Override
public boolean isTeleportInvulnerability()
{
return teleportInvulnerability;
}
private long _loginAttackDelay()
{
return config.getLong("login-attack-delay", 0) * 1000;
}
@Override
public long getLoginAttackDelay()
{
return _loginAttackDelay();
}
}

View File

@ -308,6 +308,9 @@ repair-enchanted: true
#If you set this to true any plugin that uses teleport will have the previous location registered.
register-back-in-listener: false
#Delay to wait before people can cause attack damage after logging in
login-attack-delay: 0
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #