diff --git a/docs/config.md b/docs/config.md index 10980d8a..4bf54286 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,5 @@ - + ## AuthMe Configuration The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, @@ -124,7 +124,7 @@ settings: # The value 0 means an unlimited number of registrations! maxRegPerIp: 1 # Minimum allowed username length - minNicknameLength: 4 + minNicknameLength: 3 # Maximum allowed username length maxNicknameLength: 16 # When this setting is enabled, online players can't be kicked out @@ -199,6 +199,10 @@ settings: noTeleport: false # Regex syntax for allowed chars in passwords allowedPasswordCharacters: '[\x21-\x7E]*' + # Threshold of the other accounts command, a value less than 1 means disabled. + otherAccountsCmdThreshold: 0 + # The other accounts command, available variables: %playername%, %playerip% + otherAccountsCmd: 'say The player %playername% with ip %playerip% has multiple accounts!' # Log level: INFO, FINE, DEBUG. Use INFO for general messages, # FINE for some additional detailed ones (like password failed), # and DEBUG for debugging @@ -246,9 +250,11 @@ settings: # AuthMe will update the password to the new password hash supportOldPasswordHash: false # Prevent unsafe passwords from being used; put them in lowercase! + # You should always set 'help' as unsafePassword due to possible conflicts. # unsafePasswords: # - '123456' # - 'password' + # - 'help' unsafePasswords: - '123456' - 'password' @@ -256,6 +262,7 @@ settings: - '12345' - '54321' - '123456789' + - 'help' registration: # Enable registration on the server? enabled: true @@ -378,7 +385,9 @@ Protection: - 'A1' # Do we need to enable automatic antibot system? enableAntiBot: true - # Max number of players allowed to login in 5 secs + # The interval in seconds + antiBotInterval: 5 + # Max number of players allowed to login in the interval # before the AntiBot system is enabled automatically antiBotSensibility: 10 # Duration in minutes of the antibot automatic system @@ -408,9 +417,6 @@ Security: # Take care with this, if you set this to false, # AuthMe will automatically disable and the server won't be protected! stopServer: true - ReloadCommand: - # /reload support - useReloadCommandSupport: true console: # Remove passwords from console? removePassword: true @@ -455,4 +461,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 Oct 23 21:08:57 CEST 2016 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 30 12:57:15 CET 2016 diff --git a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index ee91971b..2002232d 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -223,7 +223,11 @@ public class AsynchronousLogin implements AsynchronousProcess { player.setNoDamageTicks(0); service.send(player, MessageKey.LOGIN_SUCCESS); - displayOtherAccounts(auth, player); + + // Other auths + List auths = dataSource.getAllAuthsByIp(auth.getIp()); + runCommandOtherAccounts(auths, player, auth.getIp()); + displayOtherAccounts(auths, player); final String email = auth.getEmail(); if (service.getProperty(EmailSettings.RECALL_PLAYERS) @@ -251,12 +255,29 @@ public class AsynchronousLogin implements AsynchronousProcess { } } - private void displayOtherAccounts(PlayerAuth auth, Player player) { - if (!service.getProperty(RestrictionSettings.DISPLAY_OTHER_ACCOUNTS) || auth == null) { + private void runCommandOtherAccounts(List auths, Player player, String ip) { + int threshold = service.getProperty(RestrictionSettings.OTHER_ACCOUNTS_CMD_THRESHOLD); + String command = service.getProperty(RestrictionSettings.OTHER_ACCOUNTS_CMD); + + if(threshold <= 1 || command.isEmpty()) { + return; + } + + if (auths.size() >= threshold) { + return; + } + + bukkitService.dispatchConsoleCommand(command + .replaceAll("%playername%", player.getName()) + .replaceAll("%playerip%", ip) + ); + } + + private void displayOtherAccounts(List auths, Player player) { + if (!service.getProperty(RestrictionSettings.DISPLAY_OTHER_ACCOUNTS)) { return; } - List auths = dataSource.getAllAuthsByIp(auth.getIp()); if (auths.size() <= 1) { return; } diff --git a/src/main/java/fr/xephi/authme/service/BukkitService.java b/src/main/java/fr/xephi/authme/service/BukkitService.java index cd5595ff..e94d68cb 100644 --- a/src/main/java/fr/xephi/authme/service/BukkitService.java +++ b/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -308,4 +308,12 @@ public class BukkitService implements SettingsDependent { return Bukkit.getServer().getBanList(BanList.Type.IP).addBan(ip, reason, expires, source); } + /** + * Dispatch a command as console + * + * @param command the command + */ + public void dispatchConsoleCommand(String command) { + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); + } } diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java index c05efa4b..87e0419e 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -4,6 +4,7 @@ import com.github.authme.configme.Comment; import com.github.authme.configme.SettingsHolder; import com.github.authme.configme.properties.Property; +import javax.inject.Inject; import java.util.List; import static com.github.authme.configme.properties.PropertyInitializer.newListProperty; @@ -187,6 +188,14 @@ public class RestrictionSettings implements SettingsHolder { public static final Property> UNRESTRICTED_NAMES = newLowercaseListProperty("settings.unrestrictions.UnrestrictedName"); + @Comment("Threshold of the other accounts command, a value less than 1 means disabled.") + public static final Property OTHER_ACCOUNTS_CMD_THRESHOLD = + newProperty("settings.restrictions.otherAccountsCmdThreshold", 0); + + @Comment("The other accounts command, available variables: %playername%, %playerip%") + public static final Property OTHER_ACCOUNTS_CMD = + newProperty("settings.restrictions.otherAccountsCmd", + "say The player %playername% with ip %playerip% has multiple accounts!"); private RestrictionSettings() { }