mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-07 19:08:02 +02:00
Implement #794
This commit is contained in:
parent
351ab684e8
commit
3ea250cb10
@ -1,5 +1,5 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- 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
|
## AuthMe Configuration
|
||||||
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
|
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
|
# How many minutes before resetting the count for failed logins by IP and username
|
||||||
# Default: 480 minutes (8 hours)
|
# Default: 480 minutes (8 hours)
|
||||||
minutesBeforeCounterReset: 480
|
minutesBeforeCounterReset: 480
|
||||||
|
# If not empty this command will be executed instead of using the internal server ban system.
|
||||||
|
# Available placeholders: %player%, %ip%
|
||||||
|
customCommand: ''
|
||||||
recoveryCode:
|
recoveryCode:
|
||||||
# Number of characters a recovery code should have (0 to disable)
|
# Number of characters a recovery code should have (0 to disable)
|
||||||
length: 8
|
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
|
||||||
|
@ -17,7 +17,6 @@ import java.util.Map;
|
|||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeUnit;
|
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;
|
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 threshold;
|
||||||
private int length;
|
private int length;
|
||||||
private long resetThreshold;
|
private long resetThreshold;
|
||||||
|
private String customCommand;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TempbanManager(BukkitService bukkitService, Messages messages, Settings settings) {
|
TempbanManager(BukkitService bukkitService, Messages messages, Settings settings) {
|
||||||
@ -95,6 +95,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
|
|||||||
*/
|
*/
|
||||||
public void tempbanPlayer(final Player player) {
|
public void tempbanPlayer(final Player player) {
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
|
final String name = player.getName();
|
||||||
final String ip = PlayerUtils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS);
|
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);
|
long newTime = expires.getTime() + (length * MILLIS_PER_MINUTE);
|
||||||
expires.setTime(newTime);
|
expires.setTime(newTime);
|
||||||
|
|
||||||
bukkitService.scheduleSyncDelayedTask(new Runnable() {
|
bukkitService.scheduleSyncDelayedTask(() -> {
|
||||||
@Override
|
if(customCommand.isEmpty()) {
|
||||||
public void run() {
|
|
||||||
bukkitService.banIp(ip, reason, expires, "AuthMe");
|
bukkitService.banIp(ip, reason, expires, "AuthMe");
|
||||||
player.kickPlayer(reason);
|
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.isEnabled = settings.getProperty(SecuritySettings.TEMPBAN_ON_MAX_LOGINS);
|
||||||
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
|
this.threshold = settings.getProperty(SecuritySettings.MAX_LOGIN_TEMPBAN);
|
||||||
this.length = settings.getProperty(SecuritySettings.TEMPBAN_LENGTH);
|
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
|
@Override
|
||||||
|
@ -107,6 +107,11 @@ public final class SecuritySettings implements SettingsHolder {
|
|||||||
public static final Property<Integer> TEMPBAN_MINUTES_BEFORE_RESET =
|
public static final Property<Integer> TEMPBAN_MINUTES_BEFORE_RESET =
|
||||||
newProperty("Security.tempban.minutesBeforeCounterReset", 480);
|
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)")
|
@Comment("Number of characters a recovery code should have (0 to disable)")
|
||||||
public static final Property<Integer> RECOVERY_CODE_LENGTH =
|
public static final Property<Integer> RECOVERY_CODE_LENGTH =
|
||||||
newProperty("Security.recoveryCode.length", 8);
|
newProperty("Security.recoveryCode.length", 8);
|
||||||
|
Loading…
Reference in New Issue
Block a user