#826 add setting to define the antibot interval

This commit is contained in:
Gabriele C 2016-10-23 22:05:07 +02:00
parent 50610f6305
commit 31d8b38fe5
3 changed files with 9 additions and 2 deletions

View File

@ -30,6 +30,7 @@ public class AntiBotService implements SettingsDependent {
private int duration;
private int sensibility;
private int delay;
private int interval;
// Service status
private AntiBotStatus antiBotStatus;
@ -60,6 +61,7 @@ public class AntiBotService implements SettingsDependent {
duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);
sensibility = settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY);
delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
interval = settings.getProperty(ProtectionSettings.ANTIBOT_INTERVAL);
// Stop existing protection
stopProtection();
@ -174,7 +176,7 @@ public class AntiBotService implements SettingsDependent {
public void run() {
antibotPlayers--;
}
}, 5 * TICKS_PER_SECOND);
}, interval * TICKS_PER_SECOND);
}
/**

View File

@ -37,8 +37,12 @@ public class ProtectionSettings implements SettingsHolder {
public static final Property<Boolean> ENABLE_ANTIBOT =
newProperty("Protection.enableAntiBot", true);
@Comment("The interval in seconds")
public static final Property<Integer> ANTIBOT_INTERVAL =
newProperty("Protection.antiBotInterval", 5);
@Comment({
"Max number of players allowed to login in 5 secs",
"Max number of players allowed to login in the interval",
"before the AntiBot system is enabled automatically"})
public static final Property<Integer> ANTIBOT_SENSIBILITY =
newProperty("Protection.antiBotSensibility", 10);

View File

@ -52,6 +52,7 @@ public class AntiBotServiceTest {
@BeforeInjecting
public void initSettings() {
given(settings.getProperty(ProtectionSettings.ANTIBOT_DURATION)).willReturn(10);
given(settings.getProperty(ProtectionSettings.ANTIBOT_INTERVAL)).willReturn(5);
given(settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY)).willReturn(5);
given(settings.getProperty(ProtectionSettings.ENABLE_ANTIBOT)).willReturn(true);
given(settings.getProperty(ProtectionSettings.ANTIBOT_DELAY)).willReturn(8);