This commit is contained in:
Gabriele C 2017-09-30 19:57:27 +02:00
parent 351ab684e8
commit 3ea250cb10
3 changed files with 21 additions and 7 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sun Sep 17 11:29:06 CEST 2017. See docs/config/config.tpl.md -->
<!-- File auto-generated on Sat Sep 30 19:52:39 CEST 2017. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -442,6 +442,9 @@ Security:
# How many minutes before resetting the count for failed logins by IP and username
# Default: 480 minutes (8 hours)
minutesBeforeCounterReset: 480
# If not empty this command will be executed instead of using the internal server ban system.
# Available placeholders: %player%, %ip%
customCommand: ''
recoveryCode:
# Number of characters a recovery code should have (0 to disable)
length: 8
@ -540,4 +543,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Sep 17 11:29:06 CEST 2017
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Sep 30 19:52:39 CEST 2017

View File

@ -17,7 +17,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
import static fr.xephi.authme.settings.properties.SecuritySettings.TEMPBAN_MINUTES_BEFORE_RESET;
import static fr.xephi.authme.util.Utils.MILLIS_PER_MINUTE;
/**
@ -33,6 +32,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
private int threshold;
private int length;
private long resetThreshold;
private String customCommand;
@Inject
TempbanManager(BukkitService bukkitService, Messages messages, Settings settings) {
@ -95,6 +95,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
*/
public void tempbanPlayer(final Player player) {
if (isEnabled) {
final String name = player.getName();
final String ip = PlayerUtils.getPlayerIp(player);
final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS);
@ -102,11 +103,15 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
long newTime = expires.getTime() + (length * MILLIS_PER_MINUTE);
expires.setTime(newTime);
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
bukkitService.scheduleSyncDelayedTask(() -> {
if(customCommand.isEmpty()) {
bukkitService.banIp(ip, reason, expires, "AuthMe");
player.kickPlayer(reason);
} else {
String command = customCommand
.replaceAll("%player%", name)
.replaceAll("%ip%", ip);
bukkitService.dispatchConsoleCommand(command);
}
});
@ -119,7 +124,8 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
this.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);
this.resetThreshold = settings.getProperty(TEMPBAN_MINUTES_BEFORE_RESET);
this.resetThreshold = settings.getProperty(SecuritySettings.TEMPBAN_MINUTES_BEFORE_RESET);
this.customCommand = settings.getProperty(SecuritySettings.TEMPBAN_CUSTOM_COMMAND);
}
@Override

View File

@ -107,6 +107,11 @@ public final class SecuritySettings implements SettingsHolder {
public static final Property<Integer> TEMPBAN_MINUTES_BEFORE_RESET =
newProperty("Security.tempban.minutesBeforeCounterReset", 480);
@Comment({"If not empty this command will be executed instead of using the internal server ban system.",
"Available placeholders: %player%, %ip%"})
public static final Property<String> TEMPBAN_CUSTOM_COMMAND =
newProperty("Security.tempban.customCommand", "");
@Comment("Number of characters a recovery code should have (0 to disable)")
public static final Property<Integer> RECOVERY_CODE_LENGTH =
newProperty("Security.recoveryCode.length", 8);