diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 49285b057..b40d807bf 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -35,7 +35,6 @@ import fr.xephi.authme.permission.PermissionsSystemType; import fr.xephi.authme.process.Management; import fr.xephi.authme.security.crypts.SHA256; import fr.xephi.authme.settings.NewSetting; -import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SettingsMigrationService; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.DatabaseSettings; @@ -205,13 +204,6 @@ public class AuthMe extends JavaPlugin { // Apply settings to the logger ConsoleLogger.setLoggingOptions(newSettings); - // Old settings manager - if (!loadSettings()) { - getServer().shutdown(); - setEnabled(false); - return; - } - // Connect to the database and setup tables try { setupDatabase(newSettings); @@ -373,22 +365,10 @@ public class AuthMe extends JavaPlugin { } /** - * Load the plugin's settings. + * Loads the plugin's settings. * - * @return True on success, false on failure. + * @return The settings instance, or null if it could not be constructed */ - private boolean loadSettings() { - try { - new Settings(this); - return true; - } catch (Exception e) { - ConsoleLogger.logException("Can't load the configuration file... Something went wrong. " - + "To avoid security issues the server will shut down!", e); - getServer().shutdown(); - } - return false; - } - private NewSetting createNewSetting() { File configFile = new File(getDataFolder(), "config.yml"); PropertyMap properties = SettingsFieldRetriever.getAllPropertyFields(); diff --git a/src/main/java/fr/xephi/authme/permission/AuthGroupHandler.java b/src/main/java/fr/xephi/authme/permission/AuthGroupHandler.java index 508bb1acf..6042bf81d 100644 --- a/src/main/java/fr/xephi/authme/permission/AuthGroupHandler.java +++ b/src/main/java/fr/xephi/authme/permission/AuthGroupHandler.java @@ -5,7 +5,7 @@ import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.PlayerData; import fr.xephi.authme.initialization.Reloadable; import fr.xephi.authme.settings.NewSetting; -import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.SecuritySettings; import org.bukkit.entity.Player; @@ -116,8 +116,8 @@ public class AuthGroupHandler implements Reloadable { @Override public void reload() { unloggedInGroup = settings.getProperty(SecuritySettings.UNLOGGEDIN_GROUP); - unregisteredGroup = Settings.unRegisteredGroup; - registeredGroup = Settings.getRegisteredGroup; + unregisteredGroup = settings.getProperty(HooksSettings.UNREGISTERED_GROUP); + registeredGroup = settings.getProperty(HooksSettings.REGISTERED_GROUP); } } 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 ad6f092cf..cd10a69b5 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncEmailRegister.java @@ -5,7 +5,7 @@ import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.permission.AuthGroupType; import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.SynchronousProcess; -import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.task.PlayerDataTaskManager; import fr.xephi.authme.util.Utils; import org.bukkit.entity.Player; @@ -26,7 +26,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess { public void processEmailRegister(Player player) { final String name = player.getName().toLowerCase(); - if (!Settings.getRegisteredGroup.isEmpty()) { + if (!service.getProperty(HooksSettings.REGISTERED_GROUP).isEmpty()) { service.setGroup(player, AuthGroupType.REGISTERED); } service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED); diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java index 0471198c1..a7ea4aeb8 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncPasswordRegister.java @@ -7,8 +7,8 @@ import fr.xephi.authme.permission.AuthGroupType; import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.process.SynchronousProcess; import fr.xephi.authme.service.BungeeService; -import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.properties.EmailSettings; +import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.task.PlayerDataTaskManager; import fr.xephi.authme.util.Utils; @@ -63,7 +63,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess { } public void processPasswordRegister(Player player) { - if (!Settings.getRegisteredGroup.isEmpty()) { + if (!service.getProperty(HooksSettings.REGISTERED_GROUP).isEmpty()) { service.setGroup(player, AuthGroupType.REGISTERED); } diff --git a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java index f21225a02..57e8b6a87 100644 --- a/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java +++ b/src/main/java/fr/xephi/authme/process/unregister/AsynchronousUnregister.java @@ -10,13 +10,12 @@ import fr.xephi.authme.permission.AuthGroupType; import fr.xephi.authme.process.AsynchronousProcess; import fr.xephi.authme.process.ProcessService; import fr.xephi.authme.security.PasswordSecurity; -import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.task.PlayerDataTaskManager; import fr.xephi.authme.util.BukkitService; import fr.xephi.authme.util.TeleportationService; - import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -67,7 +66,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { teleportationService.teleportOnJoin(player); player.saveData(); playerCache.removePlayer(player.getName().toLowerCase()); - if (!Settings.getRegisteredGroup.isEmpty()) { + if (!service.getProperty(HooksSettings.REGISTERED_GROUP).isEmpty()) { service.setGroup(player, AuthGroupType.UNREGISTERED); } limboCache.deletePlayerData(player); @@ -79,7 +78,7 @@ public class AsynchronousUnregister implements AsynchronousProcess { ConsoleLogger.info(player.getName() + " unregistered himself"); return; // TODO ljacqu 20160612: Why return here? No blind effect? Player not removed from PlayerCache? } - if (!Settings.unRegisteredGroup.isEmpty()) { + if (!service.getProperty(HooksSettings.UNREGISTERED_GROUP).isEmpty()) { service.setGroup(player, AuthGroupType.UNREGISTERED); } playerCache.removePlayer(name); diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java deleted file mode 100644 index c35b2a8c0..000000000 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ /dev/null @@ -1,25 +0,0 @@ -package fr.xephi.authme.settings; - -import fr.xephi.authme.AuthMe; -import org.bukkit.configuration.file.FileConfiguration; - -/** - * Old settings manager. See {@link NewSetting} for the new manager. - */ -@Deprecated -public final class Settings { - - public static String unRegisteredGroup; - public static String getRegisteredGroup; - - /** - * Constructor for Settings. - * - * @param pl AuthMe - */ - public Settings(AuthMe pl) { - FileConfiguration configFile = pl.getConfig(); - unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", ""); - getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", ""); - } -} diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index 0ad73cdda..1fc80ce6b 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -67,7 +67,8 @@ public class SettingsMigrationService { String[] deprecatedProperties = { "Converter.Rakamak.newPasswordHash", "Hooks.chestshop", "Hooks.legacyChestshop", "Hooks.notifications", "Passpartu", "Performances", "settings.restrictions.enablePasswordVerifier", "Xenoforo.predefinedSalt", - "VeryGames", "settings.restrictions.allowAllCommandsIfRegistrationIsOptional"}; + "VeryGames", "settings.restrictions.allowAllCommandsIfRegistrationIsOptional", "DataSource.mySQLWebsite", + "Hooks.customAttributes", "Security.stop.kickPlayersBeforeStopping"}; for (String deprecatedPath : deprecatedProperties) { if (configuration.contains(deprecatedPath)) { return true; diff --git a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java index eedce4649..f9e59c93e 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java @@ -50,7 +50,7 @@ public class DatabaseSettings implements SettingsClass { public static final Property MYSQL_COL_NAME = newProperty("DataSource.mySQLColumnName", "username"); - @Comment("Column for storing or checking players RealName ") + @Comment("Column for storing or checking players RealName") public static final Property MYSQL_COL_REALNAME = newProperty("DataSource.mySQLRealName", "realname"); @@ -98,10 +98,6 @@ public class DatabaseSettings implements SettingsClass { public static final Property MYSQL_COL_GROUP = newProperty("ExternalBoardOptions.mySQLColumnGroup", ""); - @Comment("Enable this when you allow registration through a website") - public static final Property MYSQL_WEBSITE = - newProperty("DataSource.mySQLWebsite", false); - private DatabaseSettings() { } diff --git a/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java b/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java index 01e11a9cf..6bab2e81b 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/HooksSettings.java @@ -31,10 +31,6 @@ public class HooksSettings implements SettingsClass { public static final Property USE_ESSENTIALS_MOTD = newProperty("Hooks.useEssentialsMotd", false); - @Comment("Do we need to cache custom Attributes?") - public static final Property CACHE_CUSTOM_ATTRIBUTES = - newProperty("Hooks.customAttributes", false); - @Comment({ "-1 means disabled. If you want that only activated players", "can log into your server, you can set here the group number", @@ -62,6 +58,14 @@ public class HooksSettings implements SettingsClass { public static final Property WORDPRESS_TABLE_PREFIX = newProperty("ExternalBoardOptions.wordpressTablePrefix", "wp_"); + @Comment("Unregistered permission group") + public static final Property UNREGISTERED_GROUP = + newProperty("GroupOptions.UnregisteredPlayerGroup", ""); + + @Comment("Registered permission group") + public static final Property REGISTERED_GROUP = + newProperty("GroupOptions.RegisteredPlayerGroup", ""); + private HooksSettings() { } diff --git a/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java b/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java index 231833611..d9806086d 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/SecuritySettings.java @@ -42,11 +42,6 @@ public class SecuritySettings implements SettingsClass { public static final Property CAPTCHA_LENGTH = newProperty("Security.captcha.captchaLength", 5); - @Comment({"Kick players before stopping the server, that allow us to save position of players", - "and all needed information correctly without any corruption."}) - public static final Property KICK_PLAYERS_BEFORE_STOPPING = - newProperty("Security.stop.kickPlayersBeforeStopping", true); - @Comment("Minimum length of password") public static final Property MIN_PASSWORD_LENGTH = newProperty("settings.security.minPasswordLength", 5); diff --git a/src/main/java/fr/xephi/authme/settings/properties/SettingsFieldRetriever.java b/src/main/java/fr/xephi/authme/settings/properties/SettingsFieldRetriever.java index ac8d65d9f..a04deada1 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/SettingsFieldRetriever.java +++ b/src/main/java/fr/xephi/authme/settings/properties/SettingsFieldRetriever.java @@ -4,7 +4,6 @@ import fr.xephi.authme.settings.domain.Comment; import fr.xephi.authme.settings.domain.Property; import fr.xephi.authme.settings.domain.SettingsClass; import fr.xephi.authme.settings.propertymap.PropertyMap; -import fr.xephi.authme.util.StringUtils; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -67,7 +66,7 @@ public final class SettingsFieldRetriever { return (Property) field.get(null); } catch (IllegalAccessException e) { throw new IllegalStateException("Could not fetch field '" + field.getName() + "' from class '" - + field.getDeclaringClass().getSimpleName() + "': " + StringUtils.formatException(e)); + + field.getDeclaringClass().getSimpleName() + "'", e); } } return null; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3e532a650..20f2aab67 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,8 +40,6 @@ DataSource: mySQLlastlocWorld: world # Column for RealName mySQLRealName: realname - # Enable this when you allow registration through a website - mySQLWebsite: false settings: # The name shown in the help messages. helpHeader: AuthMeReloaded @@ -326,10 +324,6 @@ Security: maxLoginTry: 5 # Captcha length captchaLength: 5 - stop: - # Kick players before stopping the server, that allow us to save position of players, and all needed - # information correctly without any corruption. - kickPlayersBeforeStopping: true tempban: # Tempban a user's IP address if they enter the wrong password too many times enableTempban: false @@ -390,8 +384,6 @@ Hooks: disableSocialSpy: true # Do we need to force /motd Essentials command on join? useEssentialsMotd: false - # Do we need to cache custom Attributes? - customAttributes: false Purge: # If enabled, AuthMe automatically purges old, unused accounts useAutoPurge: false @@ -429,3 +421,8 @@ Protection: antiBotSensibility: 10 # Duration in minutes of the antibot automatic system antiBotDuration: 10 +GroupOptions: + # Registered permission group + RegisteredPlayerGroup: '' + # Unregistered permission group + UnregisteredPlayerGroup: ''