From 6341d00df076b6604ae22833b04a15c84a46d942 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Tue, 24 May 2016 18:59:01 +0200 Subject: [PATCH] Code householding - remove legacy settings and TODO messages - Remove fields in legacy settings that are now unused - Remove various irrelevant todo messages - Reduce visibility on some elements --- .../authme/command/help/HelpProvider.java | 1 - .../process/login/ProcessSyncPlayerLogin.java | 1 - .../register/ProcessSyncEmailRegister.java | 2 +- .../authme/security/PasswordSecurity.java | 2 +- .../fr/xephi/authme/settings/Settings.java | 73 ++++++++----------- .../fr/xephi/authme/settings/SpawnLoader.java | 1 - 6 files changed, 32 insertions(+), 48 deletions(-) diff --git a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java index 8a2774a5..0acf62f8 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java @@ -120,7 +120,6 @@ public class HelpProvider implements SettingsDependent { } private static void printAlternatives(CommandDescription command, List correctLabels, List lines) { - // TODO ljacqu 20151219: Need to show alternatives for base labels too? E.g. /r for /register if (command.getLabels().size() <= 1 || correctLabels.size() <= 1) { return; } diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java index 574245e6..78df4473 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncPlayerLogin.java @@ -52,7 +52,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess { private BukkitService bukkitService; @Inject - // TODO ljacqu 20160520: Need to check whether we want to inject PluginManager, or some intermediate service private PluginManager pluginManager; private final boolean restoreCollisions = MethodUtils diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java index 88397e9d..84d767ae 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java @@ -37,7 +37,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess { @Inject private AuthMe authMe; - public ProcessSyncEmailRegister() { } + ProcessSyncEmailRegister() { } public void processEmailRegister(Player player) { final String name = player.getName().toLowerCase(); diff --git a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java index 18620426..6e6eac83 100644 --- a/src/main/java/fr/xephi/authme/security/PasswordSecurity.java +++ b/src/main/java/fr/xephi/authme/security/PasswordSecurity.java @@ -151,7 +151,7 @@ public class PasswordSecurity implements Reloadable { * * @return The associated encryption method, or null if CUSTOM / deprecated */ - public EncryptionMethod initializeEncryptionMethod(HashAlgorithm algorithm) { + private EncryptionMethod initializeEncryptionMethod(HashAlgorithm algorithm) { if (HashAlgorithm.CUSTOM.equals(algorithm) || HashAlgorithm.PLAINTEXT.equals(algorithm)) { return null; } diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index e66fa2e0..af021556 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -1,7 +1,6 @@ package fr.xephi.authme.settings; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.settings.domain.Property; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.PluginSettings; @@ -11,37 +10,45 @@ import fr.xephi.authme.settings.properties.SecuritySettings; import org.bukkit.configuration.file.FileConfiguration; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import java.util.regex.Pattern; /** * Old settings manager. See {@link NewSetting} for the new manager. */ public final class Settings { - public static List allowCommands; public static List getUnrestrictedName; public static List getForcedWorlds; - public static List countries; - public static List countriesBlacklist; - public static HashAlgorithm getPasswordHash; - public static Pattern nickPattern; - public static boolean isPermissionCheckEnabled, - isForcedRegistrationEnabled, isTeleportToSpawnEnabled, - isSessionsEnabled, isAllowRestrictedIp, - isForceSingleSessionEnabled, isForceSpawnLocOnJoinEnabled, - isSaveQuitLocationEnabled, protectInventoryBeforeLogInEnabled, - isStopEnabled, reloadSupport, rakamakUseIp, - removePassword, multiverse, bungee, - enableProtection, forceRegLogin, noTeleport, - allowAllCommandsIfRegIsOptional, isRemoveSpeedEnabled; - public static String getNickRegex, getUnloggedinGroup, - unRegisteredGroup, backupWindowsPath, getRegisteredGroup, - rakamakUsers, rakamakUsersIp, defaultWorld, crazyloginFileName; - public static int getSessionTimeout, getMaxNickLength, getMinNickLength, - getNonActivatedGroup, maxLoginTry, captchaLength, getMaxLoginPerIp; - protected static FileConfiguration configFile; + public static boolean isPermissionCheckEnabled; + public static boolean isForcedRegistrationEnabled; + public static boolean isTeleportToSpawnEnabled; + public static boolean isSessionsEnabled; + public static boolean isAllowRestrictedIp; + public static boolean isForceSpawnLocOnJoinEnabled; + public static boolean isSaveQuitLocationEnabled; + public static boolean protectInventoryBeforeLogInEnabled; + public static boolean isStopEnabled; + public static boolean reloadSupport; + public static boolean rakamakUseIp; + public static boolean removePassword; + public static boolean multiverse; + public static boolean bungee; + public static boolean forceRegLogin; + public static boolean noTeleport; + public static boolean isRemoveSpeedEnabled; + public static String getUnloggedinGroup; + public static String unRegisteredGroup; + public static String getRegisteredGroup; + public static String rakamakUsers; + public static String rakamakUsersIp; + public static String defaultWorld; + public static String crazyloginFileName; + public static int getSessionTimeout; + public static int getNonActivatedGroup; + public static int maxLoginTry; + public static int captchaLength; + public static int getMaxLoginPerIp; + private static FileConfiguration configFile; /** * Constructor for Settings. @@ -59,16 +66,10 @@ public final class Settings { isTeleportToSpawnEnabled = load(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN); isSessionsEnabled = load(PluginSettings.SESSIONS_ENABLED); getSessionTimeout = configFile.getInt("settings.sessions.timeout", 10); - getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength", 20); - getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength", 3); - getNickRegex = load(RestrictionSettings.ALLOWED_NICKNAME_CHARACTERS); - nickPattern = Pattern.compile(getNickRegex); isAllowRestrictedIp = load(RestrictionSettings.ENABLE_RESTRICTED_USERS); isRemoveSpeedEnabled = load(RestrictionSettings.REMOVE_SPEED); - isForceSingleSessionEnabled = load(RestrictionSettings.FORCE_SINGLE_SESSION); isForceSpawnLocOnJoinEnabled = load(RestrictionSettings.FORCE_SPAWN_LOCATION_AFTER_LOGIN); isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false); - getPasswordHash = load(SecuritySettings.PASSWORD_HASH); getUnloggedinGroup = load(SecuritySettings.UNLOGGEDIN_GROUP); getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1); unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", ""); @@ -80,20 +81,9 @@ public final class Settings { getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", ""); protectInventoryBeforeLogInEnabled = load(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN); - backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\"); isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true); reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true); - allowAllCommandsIfRegIsOptional = load(RestrictionSettings.ALLOW_ALL_COMMANDS_IF_REGISTRATION_IS_OPTIONAL); - allowCommands = new ArrayList<>(); - allowCommands.addAll(Arrays.asList("/login", "/l", "/register", "/reg", "/email", "/captcha")); - for (String cmd : configFile.getStringList("settings.restrictions.allowCommands")) { - cmd = cmd.toLowerCase(); - if (!allowCommands.contains(cmd)) { - allowCommands.add(cmd); - } - } - rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak"); rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak"); rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false); @@ -104,9 +94,6 @@ public final class Settings { bungee = load(HooksSettings.BUNGEECORD); getForcedWorlds = load(RestrictionSettings.FORCE_SPAWN_ON_WORLDS); defaultWorld = configFile.getString("Purge.defaultWorld", "world"); - enableProtection = configFile.getBoolean("Protection.enableProtection", false); - countries = configFile.getStringList("Protection.countries"); - countriesBlacklist = configFile.getStringList("Protection.countriesBlacklist"); forceRegLogin = load(RegistrationSettings.FORCE_LOGIN_AFTER_REGISTER); getMaxLoginPerIp = load(RestrictionSettings.MAX_LOGIN_PER_IP); noTeleport = load(RestrictionSettings.NO_TELEPORT); diff --git a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java index b2d366ae..012eb053 100644 --- a/src/main/java/fr/xephi/authme/settings/SpawnLoader.java +++ b/src/main/java/fr/xephi/authme/settings/SpawnLoader.java @@ -201,7 +201,6 @@ public class SpawnLoader implements SettingsDependent { } private boolean saveAuthMeConfig() { - // TODO ljacqu 20160312: Investigate whether this utility should be put in a Utils class try { authMeConfiguration.save(authMeConfigurationFile); return true;