#761 Add group options as Property objects and #449 remove legacy Settings class

This commit is contained in:
ljacqu
2016-07-23 15:34:48 +02:00
parent 18a9fbaa26
commit bcc31afb90
12 changed files with 29 additions and 83 deletions
@@ -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", "");
}
}
@@ -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;
@@ -50,7 +50,7 @@ public class DatabaseSettings implements SettingsClass {
public static final Property<String> 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<String> MYSQL_COL_REALNAME =
newProperty("DataSource.mySQLRealName", "realname");
@@ -98,10 +98,6 @@ public class DatabaseSettings implements SettingsClass {
public static final Property<String> MYSQL_COL_GROUP =
newProperty("ExternalBoardOptions.mySQLColumnGroup", "");
@Comment("Enable this when you allow registration through a website")
public static final Property<Boolean> MYSQL_WEBSITE =
newProperty("DataSource.mySQLWebsite", false);
private DatabaseSettings() {
}
@@ -31,10 +31,6 @@ public class HooksSettings implements SettingsClass {
public static final Property<Boolean> USE_ESSENTIALS_MOTD =
newProperty("Hooks.useEssentialsMotd", false);
@Comment("Do we need to cache custom Attributes?")
public static final Property<Boolean> 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<String> WORDPRESS_TABLE_PREFIX =
newProperty("ExternalBoardOptions.wordpressTablePrefix", "wp_");
@Comment("Unregistered permission group")
public static final Property<String> UNREGISTERED_GROUP =
newProperty("GroupOptions.UnregisteredPlayerGroup", "");
@Comment("Registered permission group")
public static final Property<String> REGISTERED_GROUP =
newProperty("GroupOptions.RegisteredPlayerGroup", "");
private HooksSettings() {
}
@@ -42,11 +42,6 @@ public class SecuritySettings implements SettingsClass {
public static final Property<Integer> 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<Boolean> KICK_PLAYERS_BEFORE_STOPPING =
newProperty("Security.stop.kickPlayersBeforeStopping", true);
@Comment("Minimum length of password")
public static final Property<Integer> MIN_PASSWORD_LENGTH =
newProperty("settings.security.minPasswordLength", 5);
@@ -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;