mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 18:55:11 +01:00
#347 Add remaining missing properties
This commit is contained in:
parent
ac164c73b9
commit
fb6cff2e07
@ -0,0 +1,29 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
|
||||
public class BackupSettings implements SettingsClass {
|
||||
|
||||
@Comment("Enable or disable automatic backup")
|
||||
public static final Property<Boolean> ENABLED =
|
||||
newProperty("BackupSystem.ActivateBackup", false);
|
||||
|
||||
@Comment("Set backup at every start of server")
|
||||
public static final Property<Boolean> ON_SERVER_START =
|
||||
newProperty("BackupSystem.OnServerStart", false);
|
||||
|
||||
@Comment("Set backup at every stop of server")
|
||||
public static final Property<Boolean> ON_SERVER_STOP =
|
||||
newProperty("BackupSystem.OnServerStop", true);
|
||||
|
||||
@Comment(" Windows only mysql installation Path")
|
||||
public static final Property<String> MYSQL_WINDOWS_PATH =
|
||||
newProperty("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
|
||||
|
||||
private BackupSettings() {
|
||||
}
|
||||
}
|
@ -6,8 +6,6 @@ import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.BOOLEAN;
|
||||
import static fr.xephi.authme.settings.domain.PropertyType.STRING;
|
||||
|
||||
public class DatabaseSettings implements SettingsClass {
|
||||
|
||||
@ -18,91 +16,91 @@ public class DatabaseSettings implements SettingsClass {
|
||||
|
||||
@Comment("Enable database caching, should improve database performance")
|
||||
public static final Property<Boolean> USE_CACHING =
|
||||
newProperty(BOOLEAN, "DataSource.caching", true);
|
||||
newProperty("DataSource.caching", true);
|
||||
|
||||
@Comment("Database host address")
|
||||
public static final Property<String> MYSQL_HOST =
|
||||
newProperty(STRING, "DataSource.mySQLHost", "127.0.0.1");
|
||||
newProperty("DataSource.mySQLHost", "127.0.0.1");
|
||||
|
||||
@Comment("Database port")
|
||||
public static final Property<String> MYSQL_PORT =
|
||||
newProperty(STRING, "DataSource.mySQLPort", "3306");
|
||||
newProperty("DataSource.mySQLPort", "3306");
|
||||
|
||||
@Comment("Username about Database Connection Infos")
|
||||
public static final Property<String> MYSQL_USERNAME =
|
||||
newProperty(STRING, "DataSource.mySQLUsername", "authme");
|
||||
newProperty("DataSource.mySQLUsername", "authme");
|
||||
|
||||
@Comment("Password about Database Connection Infos")
|
||||
public static final Property<String> MYSQL_PASSWORD =
|
||||
newProperty(STRING, "DataSource.mySQLPassword", "123456");
|
||||
newProperty("DataSource.mySQLPassword", "123456");
|
||||
|
||||
@Comment("Database Name, use with converters or as SQLITE database name")
|
||||
public static final Property<String> MYSQL_DATABASE =
|
||||
newProperty(STRING, "DataSource.mySQLDatabase", "authme");
|
||||
newProperty("DataSource.mySQLDatabase", "authme");
|
||||
|
||||
@Comment("Table of the database")
|
||||
public static final Property<String> MYSQL_TABLE =
|
||||
newProperty(STRING, "DataSource.mySQLTablename", "authme");
|
||||
newProperty("DataSource.mySQLTablename", "authme");
|
||||
|
||||
@Comment("Column of IDs to sort data")
|
||||
public static final Property<String> MYSQL_COL_ID =
|
||||
newProperty(STRING, "DataSource.mySQLColumnId", "id");
|
||||
newProperty("DataSource.mySQLColumnId", "id");
|
||||
|
||||
@Comment("Column for storing or checking players nickname")
|
||||
public static final Property<String> MYSQL_COL_NAME =
|
||||
newProperty(STRING, "DataSource.mySQLColumnName", "username");
|
||||
newProperty("DataSource.mySQLColumnName", "username");
|
||||
|
||||
@Comment("Column for storing or checking players RealName ")
|
||||
public static final Property<String> MYSQL_COL_REALNAME =
|
||||
newProperty(STRING, "DataSource.mySQLRealName", "realname");
|
||||
newProperty("DataSource.mySQLRealName", "realname");
|
||||
|
||||
@Comment("Column for storing players passwords")
|
||||
public static final Property<String> MYSQL_COL_PASSWORD =
|
||||
newProperty(STRING, "DataSource.mySQLColumnPassword", "password");
|
||||
newProperty("DataSource.mySQLColumnPassword", "password");
|
||||
|
||||
@Comment("Column for storing players passwords salts")
|
||||
public static final Property<String> MYSQL_COL_SALT =
|
||||
newProperty(STRING, "ExternalBoardOptions.mySQLColumnSalt", "");
|
||||
newProperty("ExternalBoardOptions.mySQLColumnSalt", "");
|
||||
|
||||
@Comment("Column for storing players emails")
|
||||
public static final Property<String> MYSQL_COL_EMAIL =
|
||||
newProperty(STRING, "DataSource.mySQLColumnEmail", "email");
|
||||
newProperty("DataSource.mySQLColumnEmail", "email");
|
||||
|
||||
@Comment("Column for storing if a player is logged in or not")
|
||||
public static final Property<String> MYSQL_COL_ISLOGGED =
|
||||
newProperty(STRING, "DataSource.mySQLColumnLogged", "isLogged");
|
||||
newProperty("DataSource.mySQLColumnLogged", "isLogged");
|
||||
|
||||
@Comment("Column for storing players ips")
|
||||
public static final Property<String> MYSQL_COL_IP =
|
||||
newProperty(STRING, "DataSource.mySQLColumnIp", "ip");
|
||||
newProperty("DataSource.mySQLColumnIp", "ip");
|
||||
|
||||
@Comment("Column for storing players lastlogins")
|
||||
public static final Property<String> MYSQL_COL_LASTLOGIN =
|
||||
newProperty(STRING, "DataSource.mySQLColumnLastLogin", "lastlogin");
|
||||
newProperty("DataSource.mySQLColumnLastLogin", "lastlogin");
|
||||
|
||||
@Comment("Column for storing player LastLocation - X")
|
||||
public static final Property<String> MYSQL_COL_LASTLOC_X =
|
||||
newProperty(STRING, "DataSource.mySQLlastlocX", "x");
|
||||
newProperty("DataSource.mySQLlastlocX", "x");
|
||||
|
||||
@Comment("Column for storing player LastLocation - Y")
|
||||
public static final Property<String> MYSQL_COL_LASTLOC_Y =
|
||||
newProperty(STRING, "DataSource.mySQLlastlocY", "y");
|
||||
newProperty("DataSource.mySQLlastlocY", "y");
|
||||
|
||||
@Comment("Column for storing player LastLocation - Z")
|
||||
public static final Property<String> MYSQL_COL_LASTLOC_Z =
|
||||
newProperty(STRING, "DataSource.mySQLlastlocZ", "z");
|
||||
newProperty("DataSource.mySQLlastlocZ", "z");
|
||||
|
||||
@Comment("Column for storing player LastLocation - World Name")
|
||||
public static final Property<String> MYSQL_COL_LASTLOC_WORLD =
|
||||
newProperty(STRING, "DataSource.mySQLlastlocWorld", "world");
|
||||
newProperty("DataSource.mySQLlastlocWorld", "world");
|
||||
|
||||
@Comment("Column for storing players groups")
|
||||
public static final Property<String> MYSQL_COL_GROUP =
|
||||
newProperty(STRING, "ExternalBoardOptions.mySQLColumnGroup", "");
|
||||
newProperty("ExternalBoardOptions.mySQLColumnGroup", "");
|
||||
|
||||
@Comment("Enable this when you allow registration through a website")
|
||||
public static final Property<Boolean> MYSQL_WEBSITE =
|
||||
newProperty(BOOLEAN, "DataSource.mySQLWebsite", false);
|
||||
newProperty("DataSource.mySQLWebsite", false);
|
||||
|
||||
private DatabaseSettings() {
|
||||
}
|
||||
|
@ -2,8 +2,11 @@ package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.PropertyType;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
|
||||
public class HooksSettings implements SettingsClass {
|
||||
@ -36,6 +39,33 @@ public class HooksSettings implements SettingsClass {
|
||||
public static final Property<Boolean> ENABLE_VERYGAMES_IP_CHECK =
|
||||
newProperty("VeryGames.enableIpCheck", false);
|
||||
|
||||
@Comment({
|
||||
"-1 means disabled. If you want that only activated players",
|
||||
"can log into your server, you can set here the group number",
|
||||
"of unactivated users, needed for some forum/CMS support"})
|
||||
public static final Property<Integer> NON_ACTIVATED_USERS_GROUP =
|
||||
newProperty("ExternalBoardOptions.nonActivedUserGroup", -1);
|
||||
|
||||
@Comment("Other MySQL columns where we need to put the username (case-sensitive)")
|
||||
public static final Property<List<String>> MYSQL_OTHER_USERNAME_COLS =
|
||||
newProperty(PropertyType.STRING_LIST, "ExternalBoardOptions.mySQLOtherUsernameColumns");
|
||||
|
||||
@Comment("How much log2 rounds needed in BCrypt (do not change if you do not know what it does)")
|
||||
public static final Property<Integer> BCRYPT_LOG2_ROUND =
|
||||
newProperty("ExternalBoardOptions.bCryptLog2Round", 10);
|
||||
|
||||
@Comment("phpBB table prefix defined during the phpBB installation process")
|
||||
public static final Property<String> PHPBB_TABLE_PREFIX =
|
||||
newProperty("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
|
||||
|
||||
@Comment("phpBB activated group ID; 2 is the default registered group defined by phpBB")
|
||||
public static final Property<Integer> PHPBB_ACTIVATED_GROUP_ID =
|
||||
newProperty("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
||||
|
||||
@Comment("Wordpress prefix defined during WordPress installation")
|
||||
public static final Property<String> WORDPRESS_TABLE_PREFIX =
|
||||
newProperty("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
||||
|
||||
private HooksSettings() {
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,20 @@ public class PluginSettings implements SettingsClass {
|
||||
public static final Property<Boolean> SESSIONS_EXPIRE_ON_IP_CHANGE =
|
||||
newProperty("settings.sessions.sessionExpireOnIpChange", true);
|
||||
|
||||
@Comment("Message language, available: en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt")
|
||||
public static final Property<String> MESSAGES_LANGUAGE =
|
||||
newProperty("settings.messagesLanguage", "en");
|
||||
|
||||
@Comment({
|
||||
"Take care with this option; if you don't want",
|
||||
"to use Vault and group switching of AuthMe",
|
||||
"for unloggedIn players, set this setting to true.",
|
||||
"Default is false."
|
||||
})
|
||||
public static final Property<Boolean> ENABLE_PERMISSION_CHECK =
|
||||
newProperty("permission.EnablePermissionCheck", false);
|
||||
|
||||
|
||||
private PluginSettings() {
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,101 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.settings.domain.Comment;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.domain.PropertyType;
|
||||
import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
|
||||
public class RegistrationSettings implements SettingsClass {
|
||||
|
||||
@Comment("Enable registration on the server?")
|
||||
public static final Property<Boolean> IS_ENABLED =
|
||||
newProperty("settings.registration.enabled", true);
|
||||
|
||||
@Comment({
|
||||
"Send every X seconds a message to a player to",
|
||||
"remind him that he has to login/register"})
|
||||
public static final Property<Integer> MESSAGE_INTERVAL =
|
||||
newProperty("settings.registration.messageInterval", 5);
|
||||
|
||||
@Comment({
|
||||
"Only registered and logged in players can play.",
|
||||
"See restrictions for exceptions"})
|
||||
public static final Property<Boolean> FORCE =
|
||||
newProperty("settings.registration.force", true);
|
||||
|
||||
@Comment("Do we replace password registration by an email registration method?")
|
||||
public static final Property<Boolean> USE_EMAIL_REGISTRATION =
|
||||
newProperty("settings.registration.enableEmailRegistrationSystem", false);
|
||||
|
||||
@Comment({
|
||||
"Enable double check of email when you register",
|
||||
"when it's true, registration requires that kind of command:",
|
||||
"/register <email> <confirmEmail>"})
|
||||
public static final Property<Boolean> ENABLE_CONFIRM_EMAIL =
|
||||
newProperty("settings.registration.doubleEmailCheck", false);
|
||||
|
||||
@Comment({
|
||||
"Do we force kicking player after a successful registration?",
|
||||
"Do not use with login feature below"})
|
||||
public static final Property<Boolean> FORCE_KICK_AFTER_REGISTER =
|
||||
newProperty("settings.registration.forceKickAfterRegister", false);
|
||||
|
||||
@Comment("Does AuthMe need to enforce a /login after a successful registration?")
|
||||
public static final Property<Boolean> FORCE_LOGIN_AFTER_REGISTER =
|
||||
newProperty("settings.registration.forceLoginAfterRegister", false);
|
||||
|
||||
@Comment("Force these commands after /login, without any '/', use %p to replace with player name")
|
||||
public static final Property<List<String>> FORCE_COMMANDS =
|
||||
newProperty(PropertyType.STRING_LIST, "settings.forceCommands");
|
||||
|
||||
@Comment("Force these commands after /login as service console, without any '/'. "
|
||||
+ "Use %p to replace with player name")
|
||||
public static final Property<List<String>> FORCE_COMMANDS_AS_CONSOLE =
|
||||
newProperty(PropertyType.STRING_LIST, "settings.forceCommandsAsConsole");
|
||||
|
||||
@Comment("Force these commands after /register, without any '/', use %p to replace with player name")
|
||||
public static final Property<List<String>> FORCE_REGISTER_COMMANDS =
|
||||
newProperty(PropertyType.STRING_LIST, "settings.forceRegisterCommands");
|
||||
|
||||
@Comment("Force these commands after /register as a server console, without any '/'. "
|
||||
+ "Use %p to replace with player name")
|
||||
public static final Property<List<String>> FORCE_REGISTER_COMMANDS_AS_CONSOLE =
|
||||
newProperty(PropertyType.STRING_LIST, "settings.forceRegisterCommandsAsConsole");
|
||||
|
||||
@Comment({
|
||||
"Enable to display the welcome message (welcome.txt) after a registration or a login",
|
||||
"You can use colors in this welcome.txt + some replaced strings:",
|
||||
"{PLAYER}: player name, {ONLINE}: display number of online players, {MAXPLAYERS}: display server slots,",
|
||||
"{IP}: player ip, {LOGINS}: number of players logged, {WORLD}: player current world, {SERVER}: server name",
|
||||
"{VERSION}: get current bukkit version, {COUNTRY}: player country"})
|
||||
public static final Property<Boolean> USE_WELCOME_MESSAGE =
|
||||
newProperty("settings.useWelcomeMessage", true);
|
||||
|
||||
@Comment("Do we need to broadcast the welcome message to all server or only to the player? set true for "
|
||||
+ "server or false for player")
|
||||
public static final Property<Boolean> BROADCAST_WELCOME_MESSAGE =
|
||||
newProperty("settings.broadcastWelcomeMessage", false);
|
||||
|
||||
@Comment("Do we need to delay the join/leave message to be displayed only when the player is authenticated?")
|
||||
public static final Property<Boolean> DELAY_JOIN_LEAVE_MESSAGES =
|
||||
newProperty("settings.delayJoinLeaveMessages", true);
|
||||
|
||||
@Comment("Do we need to add potion effect Blinding before login/reigster?")
|
||||
public static final Property<Boolean> APPLY_BLIND_EFFECT =
|
||||
newProperty("settings.applyBlindEffect", false);
|
||||
|
||||
@Comment({
|
||||
"Do we need to prevent people to login with another case?",
|
||||
"If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI"})
|
||||
public static final Property<Boolean> PREVENT_OTHER_CASE =
|
||||
newProperty("settings.preventOtherCase", false);
|
||||
|
||||
|
||||
private RegistrationSettings() {
|
||||
}
|
||||
|
||||
}
|
@ -165,6 +165,18 @@ public class RestrictionSettings implements SettingsClass {
|
||||
public static final Property<Boolean> FORCE_SURVIVAL_MODE =
|
||||
newProperty("settings.GameMode.ForceSurvivalMode", false);
|
||||
|
||||
@Comment({
|
||||
"Below you can list all account names that",
|
||||
"AuthMe will ignore for registration or login, configure it",
|
||||
"at your own risk!! Remember that if you are going to add",
|
||||
"nickname with [], you have to delimit name with ' '.",
|
||||
"this option add compatibility with BuildCraft and some",
|
||||
"other mods.",
|
||||
"It is case-sensitive!"
|
||||
})
|
||||
public static final Property<List<String>> UNRESTRICTED_NAMES =
|
||||
newProperty(PropertyType.STRING_LIST, "settings.unrestrictions.UnrestrictedName");
|
||||
|
||||
|
||||
private RestrictionSettings() {
|
||||
}
|
||||
|
@ -18,9 +18,10 @@ final class SettingsFieldRetriever {
|
||||
|
||||
/** The classes to scan for properties. */
|
||||
private static final List<Class<? extends SettingsClass>> CONFIGURATION_CLASSES = Arrays.asList(
|
||||
ConverterSettings.class, PluginSettings.class, RestrictionSettings.class,
|
||||
DatabaseSettings.class, EmailSettings.class, HooksSettings.class,
|
||||
ProtectionSettings.class, PurgeSettings.class, SecuritySettings.class);
|
||||
ConverterSettings.class, PluginSettings.class, RestrictionSettings.class,
|
||||
DatabaseSettings.class, EmailSettings.class, HooksSettings.class,
|
||||
ProtectionSettings.class, PurgeSettings.class, SecuritySettings.class,
|
||||
RegistrationSettings.class, BackupSettings.class);
|
||||
|
||||
private SettingsFieldRetriever() {
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ settings:
|
||||
# Only registered and logged in players can play.
|
||||
# See restrictions for exceptions
|
||||
force: true
|
||||
# Does we replace password registration by an Email registration method?
|
||||
# Do we replace password registration by an email registration method?
|
||||
enableEmailRegistrationSystem: false
|
||||
# Enable double check of email when you register
|
||||
# when it's true, registration require that kind of command:
|
||||
|
@ -1,9 +1,11 @@
|
||||
package fr.xephi.authme.settings.custom;
|
||||
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import fr.xephi.authme.settings.propertymap.PropertyMap;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -16,8 +18,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
@ -40,7 +40,19 @@ public class ConfigFileConsistencyTest {
|
||||
boolean result = settings.containsAllSettings(SettingsFieldRetriever.getAllPropertyFields());
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo(true));
|
||||
if (!result) {
|
||||
FileConfiguration configuration =
|
||||
(FileConfiguration) ReflectionTestUtils.getFieldValue(NewSetting.class, settings, "configuration");
|
||||
|
||||
Set<String> knownProperties = getAllKnownPropertyPaths();
|
||||
List<String> missingProperties = new ArrayList<>();
|
||||
for (String path : knownProperties) {
|
||||
if (!configuration.contains(path)) {
|
||||
missingProperties.add(path);
|
||||
}
|
||||
}
|
||||
fail("Found missing properties!\n-" + StringUtils.join("\n-", missingProperties));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -7,6 +7,7 @@ import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
@ -14,6 +15,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.hamcrest.Matchers.arrayWithSize;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
@ -82,6 +84,17 @@ public class SettingsClassConsistencyTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveHiddenDefaultConstructorOnly() {
|
||||
for (Class<?> clazz : classes) {
|
||||
Constructor<?>[] constructors = clazz.getDeclaredConstructors();
|
||||
assertThat(clazz + " should only have one constructor",
|
||||
constructors, arrayWithSize(1));
|
||||
assertThat("Constructor of " + clazz + " is private",
|
||||
Modifier.isPrivate(constructors[0].getModifiers()), equalTo(true));
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isValidConstantField(Field field) {
|
||||
int modifiers = field.getModifiers();
|
||||
return Modifier.isPublic(modifiers) && Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers);
|
||||
|
Loading…
Reference in New Issue
Block a user