mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Add sign throttle config option.
Allows you to limit how often an Essentials sign can be spammed per player.
This commit is contained in:
parent
9f852b3a41
commit
9679a90d88
5 changed files with 49 additions and 2 deletions
|
@ -179,4 +179,6 @@ public interface ISettings extends IConf
|
|||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
|
||||
int getSignUsePerSecond();
|
||||
}
|
||||
|
|
|
@ -388,7 +388,8 @@ public class Settings implements ISettings
|
|||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
loginAttackDelay = _loginAttackDelay();
|
||||
loginAttackDelay = _getLoginAttackDelay();
|
||||
signUsePerSecond = _getSignUsePerSecond();
|
||||
kits = _getKits();
|
||||
chatFormats.clear();
|
||||
}
|
||||
|
@ -808,7 +809,7 @@ public class Settings implements ISettings
|
|||
|
||||
private long loginAttackDelay;
|
||||
|
||||
private long _loginAttackDelay()
|
||||
private long _getLoginAttackDelay()
|
||||
{
|
||||
return config.getLong("login-attack-delay", 0) * 1000;
|
||||
}
|
||||
|
@ -819,4 +820,18 @@ public class Settings implements ISettings
|
|||
return loginAttackDelay;
|
||||
}
|
||||
|
||||
private int signUsePerSecond;
|
||||
|
||||
private int _getSignUsePerSecond()
|
||||
{
|
||||
final int perSec = config.getInt("sign-use-per-second", 4);
|
||||
return perSec > 0 ? perSec : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSignUsePerSecond()
|
||||
{
|
||||
return signUsePerSecond;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||
private transient final Teleport teleport;
|
||||
private transient long teleportRequestTime;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastThrottledAction;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient Location afkPosition = null;
|
||||
|
@ -669,4 +670,23 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||
{
|
||||
final boolean set = !vanished;
|
||||
}
|
||||
|
||||
public boolean checkSignThrottle() {
|
||||
if (isSignThrottled()) {
|
||||
return true;
|
||||
}
|
||||
updateThrottle();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSignThrottled()
|
||||
{
|
||||
final long minTime = lastThrottledAction + (1000 / ess.getSettings().getSignUsePerSecond());
|
||||
return (System.currentTimeMillis() < minTime);
|
||||
}
|
||||
|
||||
public void updateThrottle()
|
||||
{
|
||||
lastThrottledAction = System.currentTimeMillis();;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@ public class EssentialsSign
|
|||
{
|
||||
final ISign sign = new BlockSign(block);
|
||||
final User user = ess.getUser(player);
|
||||
if (user.checkSignThrottle())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
return (user.isAuthorized("essentials.signs." + signName.toLowerCase(Locale.ENGLISH) + ".use")
|
||||
|
|
|
@ -222,6 +222,12 @@ enabledSigns:
|
|||
#- time
|
||||
#- weather
|
||||
#- protection
|
||||
|
||||
|
||||
# How many times per second can Essentials signs be interacted with.
|
||||
# Values should be between 1-20, 20 being virtually no lag protection.s
|
||||
# Lower numbers will reduce the possiblity of lag, but may annoy players.
|
||||
sign-use-per-second: 4
|
||||
|
||||
# Backup runs a command while saving is disabled
|
||||
backup:
|
||||
|
|
Loading…
Reference in a new issue