#826 add setting to define the antibot interval
This commit is contained in:
parent
50610f6305
commit
31d8b38fe5
@ -30,6 +30,7 @@ public class AntiBotService implements SettingsDependent {
|
|||||||
private int duration;
|
private int duration;
|
||||||
private int sensibility;
|
private int sensibility;
|
||||||
private int delay;
|
private int delay;
|
||||||
|
private int interval;
|
||||||
|
|
||||||
// Service status
|
// Service status
|
||||||
private AntiBotStatus antiBotStatus;
|
private AntiBotStatus antiBotStatus;
|
||||||
@ -60,6 +61,7 @@ public class AntiBotService implements SettingsDependent {
|
|||||||
duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);
|
duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);
|
||||||
sensibility = settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY);
|
sensibility = settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY);
|
||||||
delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
|
delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
|
||||||
|
interval = settings.getProperty(ProtectionSettings.ANTIBOT_INTERVAL);
|
||||||
|
|
||||||
// Stop existing protection
|
// Stop existing protection
|
||||||
stopProtection();
|
stopProtection();
|
||||||
@ -174,7 +176,7 @@ public class AntiBotService implements SettingsDependent {
|
|||||||
public void run() {
|
public void run() {
|
||||||
antibotPlayers--;
|
antibotPlayers--;
|
||||||
}
|
}
|
||||||
}, 5 * TICKS_PER_SECOND);
|
}, interval * TICKS_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -37,8 +37,12 @@ public class ProtectionSettings implements SettingsHolder {
|
|||||||
public static final Property<Boolean> ENABLE_ANTIBOT =
|
public static final Property<Boolean> ENABLE_ANTIBOT =
|
||||||
newProperty("Protection.enableAntiBot", true);
|
newProperty("Protection.enableAntiBot", true);
|
||||||
|
|
||||||
|
@Comment("The interval in seconds")
|
||||||
|
public static final Property<Integer> ANTIBOT_INTERVAL =
|
||||||
|
newProperty("Protection.antiBotInterval", 5);
|
||||||
|
|
||||||
@Comment({
|
@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"})
|
"before the AntiBot system is enabled automatically"})
|
||||||
public static final Property<Integer> ANTIBOT_SENSIBILITY =
|
public static final Property<Integer> ANTIBOT_SENSIBILITY =
|
||||||
newProperty("Protection.antiBotSensibility", 10);
|
newProperty("Protection.antiBotSensibility", 10);
|
||||||
|
|||||||
@ -52,6 +52,7 @@ public class AntiBotServiceTest {
|
|||||||
@BeforeInjecting
|
@BeforeInjecting
|
||||||
public void initSettings() {
|
public void initSettings() {
|
||||||
given(settings.getProperty(ProtectionSettings.ANTIBOT_DURATION)).willReturn(10);
|
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.ANTIBOT_SENSIBILITY)).willReturn(5);
|
||||||
given(settings.getProperty(ProtectionSettings.ENABLE_ANTIBOT)).willReturn(true);
|
given(settings.getProperty(ProtectionSettings.ENABLE_ANTIBOT)).willReturn(true);
|
||||||
given(settings.getProperty(ProtectionSettings.ANTIBOT_DELAY)).willReturn(8);
|
given(settings.getProperty(ProtectionSettings.ANTIBOT_DELAY)).willReturn(8);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user