mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-11-18 16:45:37 +01:00
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:
parent
fa58503c9f
commit
5eeaeaee5d
@ -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())
|
||||
|
@ -175,4 +175,6 @@ public interface ISettings extends IConf
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
}
|
||||
|
@ -798,4 +798,16 @@ public class Settings implements ISettings
|
||||
{
|
||||
return teleportInvulnerability;
|
||||
}
|
||||
|
||||
private long _loginAttackDelay()
|
||||
{
|
||||
return config.getLong("login-attack-delay", 0) * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLoginAttackDelay()
|
||||
{
|
||||
return _loginAttackDelay();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 | #
|
||||
|
Loading…
Reference in New Issue
Block a user