diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java index 71ecb4c636..30ab7e2fc0 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/initialization/OnStartupTasks.java @@ -11,6 +11,7 @@ import fr.xephi.authme.logger.Log4JFilter; import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.PluginSettings; @@ -56,7 +57,7 @@ public static void sendMetrics(AuthMe plugin, Settings settings) { final Metrics metrics = new Metrics(plugin, 18479); metrics.addCustomChart(new SimplePie("messages_language", - () -> settings.getProperty(PluginSettings.MESSAGES_LANGUAGE))); + () -> settings.getProperty(CommonSettings.MESSAGES_LANGUAGE))); metrics.addCustomChart(new SimplePie("database_backend", () -> settings.getProperty(DatabaseSettings.BACKEND).toString())); } diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/message/AbstractMessageFileHandler.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/message/AbstractMessageFileHandler.java index 758e2f6f50..2b2010842e 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/message/AbstractMessageFileHandler.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/message/AbstractMessageFileHandler.java @@ -7,6 +7,7 @@ import fr.xephi.authme.initialization.Reloadable; import fr.xephi.authme.logger.ConsoleLoggerFactory; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.util.FileUtils; import fr.xephi.authme.util.message.I18NUtils; @@ -45,7 +46,7 @@ protected AbstractMessageFileHandler() { @Override @PostConstruct public void reload() { - String language = settings.getProperty(PluginSettings.MESSAGES_LANGUAGE); + String language = getLanguage(); filename = createFilePath(language); File messagesFile = initializeFile(filename); configuration = Configuration.loadFromFile(messagesFile); @@ -53,7 +54,7 @@ public void reload() { } protected String getLanguage() { - return settings.getProperty(PluginSettings.MESSAGES_LANGUAGE); + return settings.getProperty(CommonSettings.MESSAGES_LANGUAGE); } protected File getUserLanguageFile() { diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java index 02a7c7d46f..065fb8df80 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/login/AsynchronousLogin.java @@ -28,6 +28,7 @@ import fr.xephi.authme.service.bungeecord.MessageType; import fr.xephi.authme.service.velocity.VelocitySender; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.HooksSettings; @@ -193,7 +194,7 @@ private PlayerAuth getPlayerAuth(Player player, boolean quiet) { return null; } - boolean isAsync = service.getProperty(PluginSettings.USE_ASYNC_TASKS); + boolean isAsync = service.getProperty(CommonSettings.USE_ASYNC_TASKS); AuthMeAsyncPreLoginEvent event = new AuthMeAsyncPreLoginEvent(player, isAsync); bukkitService.callEvent(event); if (!event.canLogin()) { diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index 31bb707877..21e562e93b 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -11,6 +11,7 @@ import fr.xephi.authme.service.SessionService; import fr.xephi.authme.service.ValidationService; import fr.xephi.authme.settings.SpawnLoader; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.util.PlayerUtils; import org.bukkit.Location; @@ -97,7 +98,7 @@ public void processQuit(Player player) { //always update the database when the player quit the game (if sessions are disabled) if (wasLoggedIn) { database.setUnlogged(name); - if (!service.getProperty(PluginSettings.SESSIONS_ENABLED)) { + if (!service.getProperty(CommonSettings.SESSIONS_ENABLED)) { sessionService.revokeSession(name); } } diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java index 179aa59df8..ece82bf621 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/process/register/executors/AbstractPasswordRegisterExecutor.java @@ -8,7 +8,7 @@ import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.CommonService; import fr.xephi.authme.service.ValidationService; -import fr.xephi.authme.settings.properties.PluginSettings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; import org.bukkit.entity.Player; @@ -21,7 +21,7 @@ * @param

the parameters type */ abstract class AbstractPasswordRegisterExecutor

- implements RegistrationExecutor

{ + implements RegistrationExecutor

{ /** * Number of ticks to wait before running the login action when it is run synchronously. @@ -51,7 +51,7 @@ abstract class AbstractPasswordRegisterExecutor

asynchronousLogin.forceLogin(player)); } else { bukkitService.scheduleSyncDelayedTask(() -> asynchronousLogin.forceLogin(player), SYNC_LOGIN_DELAY); diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java index 2c787306cb..5f6b62ef83 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/security/totp/TotpAuthenticator.java @@ -10,6 +10,7 @@ import fr.xephi.authme.data.auth.PlayerAuth; import fr.xephi.authme.initialization.HasCleanup; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.PluginSettings; import org.bukkit.entity.Player; @@ -68,7 +69,7 @@ public boolean checkCode(String playerName, String totpKey, String inputCode) { public TotpGenerationResult generateTotpKey(Player player) { GoogleAuthenticatorKey credentials = authenticator.createCredentials(); String qrCodeUrl = GoogleAuthenticatorQRGenerator.getOtpAuthURL( - settings.getProperty(PluginSettings.SERVER_NAME), player.getName(), credentials); + settings.getProperty(CommonSettings.SERVER_NAME), player.getName(), credentials); return new TotpGenerationResult(credentials.getKey(), qrCodeUrl); } diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/BukkitService.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/BukkitService.java index 8a89979558..c9db5e684f 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/BukkitService.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/BukkitService.java @@ -6,7 +6,7 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.settings.Settings; -import fr.xephi.authme.settings.properties.PluginSettings; +import fr.xephi.authme.settings.properties.CommonSettings; import org.bukkit.BanEntry; import org.bukkit.BanList; import org.bukkit.Bukkit; @@ -35,11 +35,17 @@ */ public class BukkitService implements SettingsDependent { - /** Number of ticks per second in the Bukkit main thread. */ + /** + * Number of ticks per second in the Bukkit main thread. + */ public static final int TICKS_PER_SECOND = 20; - /** Number of ticks per minute. */ + /** + * Number of ticks per minute. + */ public static final int TICKS_PER_MINUTE = 60 * TICKS_PER_SECOND; - /** Whether the server is running Folia. */ + /** + * Whether the server is running Folia. + */ private static final boolean isFolia = UniversalScheduler.isFolia; private final AuthMe authMe; private boolean useAsyncTasks; @@ -121,6 +127,7 @@ public void runTask(Location location, Runnable task) { /** * Runs the task synchronously if we are running Folia, else do nothing but run it. + * * @param task the task to be run */ public void runTaskIfFolia(Runnable task) { @@ -133,6 +140,7 @@ public void runTaskIfFolia(Runnable task) { /** * Runs the task synchronously if we are running Folia, else do nothing but run it. + * * @param task the task to be run */ public void runTaskIfFolia(Entity entity, Runnable task) { @@ -145,6 +153,7 @@ public void runTaskIfFolia(Entity entity, Runnable task) { /** * Runs the task synchronously if we are running Folia, else do nothing but run it. + * * @param task the task to be run */ public void runTaskIfFolia(Location location, Runnable task) { @@ -212,13 +221,13 @@ public void runTaskAsynchronously(Runnable task) { * Returns a task that will repeatedly run asynchronously until cancelled, * starting after the specified number of server ticks. * - * @param task the task to be run - * @param delay the ticks to wait before running the task for the first - * time + * @param task the task to be run + * @param delay the ticks to wait before running the task for the first + * time * @param period the ticks to wait between runs * @return a BukkitTask that contains the id number * @throws IllegalArgumentException if task is null - * @throws IllegalStateException if this was already scheduled + * @throws IllegalStateException if this was already scheduled */ public MyScheduledTask runTaskTimerAsynchronously(UniversalRunnable task, long delay, long period) { return task.runTaskTimerAsynchronously(authMe, delay, period); @@ -309,7 +318,7 @@ public Collection getOnlinePlayers() { * * @param event Event details * @throws IllegalStateException Thrown when an asynchronous event is - * fired from synchronous code. + * fired from synchronous code. */ public void callEvent(Event event) { Bukkit.getPluginManager().callEvent(event); @@ -320,7 +329,7 @@ public void callEvent(Event event) { * * @param eventSupplier the event supplier: function taking a boolean specifying whether AuthMe is configured * in async mode or not - * @param the event type + * @param the event type * @return the event that was created and emitted */ public E createAndCallEvent(Function eventSupplier) { @@ -352,7 +361,7 @@ public World getWorld(String name) { /** * Dispatches a command on this server, and executes it if found. * - * @param sender the apparent sender of the command + * @param sender the apparent sender of the command * @param commandLine the command + arguments. Example: test abc 123 * @return returns false if no target is found */ @@ -372,14 +381,14 @@ public boolean dispatchConsoleCommand(String commandLine) { @Override public void reload(Settings settings) { - useAsyncTasks = settings.getProperty(PluginSettings.USE_ASYNC_TASKS); + useAsyncTasks = settings.getProperty(CommonSettings.USE_ASYNC_TASKS); } /** * Send the specified bytes to bungeecord using the specified player connection. * * @param player the player - * @param bytes the message + * @param bytes the message */ public void sendBungeeMessage(Player player, byte[] bytes) { player.sendPluginMessage(authMe, "BungeeCord", bytes); @@ -389,7 +398,7 @@ public void sendBungeeMessage(Player player, byte[] bytes) { * Send the specified bytes to bungeecord using the specified player connection. * * @param player the player - * @param bytes the message + * @param bytes the message */ public void sendVelocityMessage(Player player, byte[] bytes) { if (player != null) { @@ -404,13 +413,13 @@ public void sendVelocityMessage(Player player, byte[] bytes) { * Adds a ban to the list. If a previous ban exists, this will * update the previous entry. * - * @param ip the ip of the ban - * @param reason reason for the ban, null indicates implementation default + * @param ip the ip of the ban + * @param reason reason for the ban, null indicates implementation default * @param expires date for the ban's expiration (unban), or null to imply - * forever - * @param source source of the ban, null indicates implementation default + * forever + * @param source source of the ban, null indicates implementation default * @return the entry for the newly created ban, or the entry for the - * (updated) previous ban + * (updated) previous ban */ public BanEntry banIp(String ip, String reason, Date expires, String source) { return Bukkit.getServer().getBanList(BanList.Type.IP).addBan(ip, reason, expires, source); diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/HelpTranslationGenerator.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/HelpTranslationGenerator.java index e1c8c5ba76..ffd9d1f60d 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/HelpTranslationGenerator.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/HelpTranslationGenerator.java @@ -11,6 +11,7 @@ import fr.xephi.authme.message.MessagePathHelper; import fr.xephi.authme.permission.DefaultPermission; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.PluginSettings; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @@ -49,7 +50,7 @@ public class HelpTranslationGenerator { * @throws IOException if the help file cannot be written to */ public File updateHelpFile() throws IOException { - String languageCode = settings.getProperty(PluginSettings.MESSAGES_LANGUAGE); + String languageCode = settings.getProperty(CommonSettings.MESSAGES_LANGUAGE); File helpFile = new File(dataFolder, MessagePathHelper.createHelpMessageFilePath(languageCode)); Map helpEntries = generateHelpMessageEntries(); diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/SessionService.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/SessionService.java index 70589f77ac..47c47ead72 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/SessionService.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/service/SessionService.java @@ -7,6 +7,7 @@ import fr.xephi.authme.initialization.Reloadable; import fr.xephi.authme.message.MessageKey; import fr.xephi.authme.logger.ConsoleLoggerFactory; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.util.PlayerUtils; import org.bukkit.entity.Player; @@ -78,7 +79,7 @@ private SessionState fetchSessionStatus(PlayerAuth auth, Player player) { long timeSinceLastLogin = System.currentTimeMillis() - auth.getLastLogin(); if (timeSinceLastLogin > 0 - && timeSinceLastLogin < service.getProperty(PluginSettings.SESSIONS_TIMEOUT) * MILLIS_PER_MINUTE) { + && timeSinceLastLogin < service.getProperty(CommonSettings.SESSIONS_TIMEOUT) * MILLIS_PER_MINUTE) { if (PlayerUtils.getPlayerIp(player).equals(auth.getLastIp())) { return SessionState.VALID; } else { @@ -100,6 +101,6 @@ public void revokeSession(String name) { @Override public void reload() { - this.isEnabled = service.getProperty(PluginSettings.SESSIONS_ENABLED); + this.isEnabled = service.getProperty(CommonSettings.SESSIONS_ENABLED); } } diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index bd28b7a5ef..8bb297a215 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -13,6 +13,7 @@ import fr.xephi.authme.process.register.RegisterSecondaryArgument; import fr.xephi.authme.process.register.RegistrationType; import fr.xephi.authme.security.HashAlgorithm; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.DatabaseSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.RegistrationSettings; @@ -222,7 +223,7 @@ private static boolean migratePoolSizeSetting(PropertyReader reader, Configurati private static boolean changeBooleanSettingToLogLevelProperty(PropertyReader reader, ConfigurationData configData) { final String oldPath = "Security.console.noConsoleSpam"; - final Property newProperty = PluginSettings.LOG_LEVEL; + final Property newProperty = CommonSettings.LOG_LEVEL; if (!newProperty.isValidInResource(reader) && reader.contains(oldPath)) { logger.info("Moving '" + oldPath + "' to '" + newProperty.getPath() + "'"); boolean oldValue = Optional.ofNullable(reader.getBoolean(oldPath)).orElse(false); diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsWarner.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsWarner.java index 8626e7a410..4f2e1ad3ac 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsWarner.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/SettingsWarner.java @@ -6,6 +6,7 @@ import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.security.crypts.Argon2; import fr.xephi.authme.service.BukkitService; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.EmailSettings; import fr.xephi.authme.settings.properties.HooksSettings; import fr.xephi.authme.settings.properties.PluginSettings; @@ -54,8 +55,8 @@ public void logWarningsForMisconfigurations() { } // Output hint if sessions are enabled that the timeout must be positive - if (settings.getProperty(PluginSettings.SESSIONS_ENABLED) - && settings.getProperty(PluginSettings.SESSIONS_TIMEOUT) <= 0) { + if (settings.getProperty(CommonSettings.SESSIONS_ENABLED) + && settings.getProperty(CommonSettings.SESSIONS_TIMEOUT) <= 0) { logger.warning("Warning: Session timeout needs to be positive in order to work!"); } diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetriever.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetriever.java index 9ddf9aa1a8..d8ac55a338 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetriever.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/AuthMeSettingsRetriever.java @@ -20,9 +20,11 @@ private AuthMeSettingsRetriever() { */ public static ConfigurationData buildConfigurationData() { return ConfigurationDataBuilder.createConfiguration( + CommonSettings.class, DatabaseSettings.class, PluginSettings.class, RestrictionSettings.class, EmailSettings.class, HooksSettings.class, ProtectionSettings.class, PurgeSettings.class, SecuritySettings.class, RegistrationSettings.class, LimboSettings.class, BackupSettings.class, ConverterSettings.class); } + } diff --git a/project/module-common/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java similarity index 69% rename from project/module-common/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java rename to plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java index b06e7a88eb..fa5a740f7a 100644 --- a/project/module-common/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java @@ -40,32 +40,6 @@ public final class PluginSettings implements SettingsHolder { newLowercaseStringSetProperty("3rdPartyFeature.features.i18nMessages.locale-code-redirect", "tt_ru:ru", "lzh:zhcn"); - @Comment({ - "Do you want to enable the session feature?", - "If enabled, when a player authenticates successfully,", - "his IP and his nickname is saved.", - "The next time the player joins the server, if his IP", - "is the same as last time and the timeout hasn't", - "expired, he will not need to authenticate." - }) - public static final Property SESSIONS_ENABLED = - newProperty("settings.sessions.enabled", true); - - @Comment({ - "After how many minutes should a session expire?", - "A player's session ends after the timeout or if his IP has changed" - }) - public static final Property SESSIONS_TIMEOUT = - newProperty("settings.sessions.timeout", 43200); - - @Comment({ - "Message language, available languages:", - "https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md", - "Example: zhcn, en" - }) - public static final Property MESSAGES_LANGUAGE = - newProperty("settings.messagesLanguage", "en"); - @Comment({ "Enables switching a player to defined permission groups before they log in.", "See below for a detailed explanation." @@ -99,21 +73,6 @@ public final class PluginSettings implements SettingsHolder { public static final Property FORCE_VAULT_HOOK = newProperty("settings.forceVaultHook", false); - @Comment({ - "Log level: INFO, FINE, DEBUG. Use INFO for general messages,", - "FINE for some additional detailed ones (like password failed),", - "and DEBUG for debugging" - }) - public static final Property LOG_LEVEL = - newProperty(LogLevel.class, "settings.logLevel", LogLevel.FINE); - - @Comment({ - "By default we schedule async tasks when talking to the database. If you want", - "typical communication with the database to happen synchronously, set this to false" - }) - public static final Property USE_ASYNC_TASKS = - newProperty("settings.useAsyncTasks", true); - @Comment("The name of the server, used in some placeholders.") public static final Property SERVER_NAME = newProperty("settings.serverName", "Your Minecraft Server"); diff --git a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/message/I18NUtils.java b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/message/I18NUtils.java index da1d6769bc..b2547bb4c6 100644 --- a/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/message/I18NUtils.java +++ b/plugin/platform-bukkit/src/main/java/fr/xephi/authme/util/message/I18NUtils.java @@ -1,6 +1,7 @@ package fr.xephi.authme.util.message; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.util.Utils; import org.bukkit.entity.Player; @@ -97,6 +98,6 @@ public static String localeToCode(String locale, Settings settings) { return locale; } - return settings.getProperty(PluginSettings.MESSAGES_LANGUAGE); + return settings.getProperty(CommonSettings.MESSAGES_LANGUAGE); } } diff --git a/project/module-common/src/main/java/fr/xephi/authme/settings/properties/CommonSettings.java b/project/module-common/src/main/java/fr/xephi/authme/settings/properties/CommonSettings.java new file mode 100644 index 0000000000..9029bdbd46 --- /dev/null +++ b/project/module-common/src/main/java/fr/xephi/authme/settings/properties/CommonSettings.java @@ -0,0 +1,62 @@ +package fr.xephi.authme.settings.properties; + +import ch.jalu.configme.Comment; +import ch.jalu.configme.SettingsHolder; +import ch.jalu.configme.properties.Property; +import fr.xephi.authme.logger.LogLevel; + +import static ch.jalu.configme.properties.PropertyInitializer.newProperty; + +/** + * CommonSettings + * + * @author TheFloodDragon + * @since 2024/7/11 20:19 + */ +public final class CommonSettings implements SettingsHolder { + + @Comment({ + "Message language, available languages:", + "https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md", + "Example: zhcn, en" + }) + public static final Property MESSAGES_LANGUAGE = + newProperty("settings.messagesLanguage", "en"); + + @Comment({ + "(Disabled since 2024.7.11) Log level: INFO, FINE, DEBUG. Use INFO for general messages,", + "FINE for some additional detailed ones (like password failed),", + "and DEBUG for debugging" + }) + public static final Property LOG_LEVEL = + newProperty(LogLevel.class, "settings.logLevel", LogLevel.FINE); + + @Comment({ + "By default we schedule async tasks when talking to the database. If you want", + "typical communication with the database to happen synchronously, set this to false" + }) + public static final Property USE_ASYNC_TASKS = + newProperty("settings.useAsyncTasks", true); + + @Comment({ + "Do you want to enable the session feature?", + "If enabled, when a player authenticates successfully,", + "his IP and his nickname is saved.", + "The next time the player joins the server, if his IP", + "is the same as last time and the timeout hasn't", + "expired, he will not need to authenticate." + }) + public static final Property SESSIONS_ENABLED = + newProperty("settings.sessions.enabled", true); + + @Comment({ + "After how many minutes should a session expire?", + "A player's session ends after the timeout or if his IP has changed" + }) + public static final Property SESSIONS_TIMEOUT = + newProperty("settings.sessions.timeout", 43200); + + @Comment("The name of the server, used in some placeholders.") + public static final Property SERVER_NAME = newProperty("settings.serverName", "Your Minecraft Server"); + +} diff --git a/project/module-mail/build.gradle.kts b/project/module-mail/build.gradle.kts index 599734c92c..7b1860d873 100644 --- a/project/module-mail/build.gradle.kts +++ b/project/module-mail/build.gradle.kts @@ -1,6 +1,7 @@ dependencies { compileOnly(project(":project:module-logger")) compileOnly(project(":project:module-util")) + compileOnly(project(":project:module-security")) compileOnly(libs.configme) compileOnly(libs.jalu.injector) // Java Email Library diff --git a/project/module-mail/src/main/java/fr/xephi/authme/mail/EmailService.java b/project/module-mail/src/main/java/fr/xephi/authme/mail/EmailService.java index 400119dca0..87f9da31c1 100644 --- a/project/module-mail/src/main/java/fr/xephi/authme/mail/EmailService.java +++ b/project/module-mail/src/main/java/fr/xephi/authme/mail/EmailService.java @@ -4,8 +4,8 @@ import fr.xephi.authme.logger.ConsoleLogger; import fr.xephi.authme.logger.ConsoleLoggerFactory; import fr.xephi.authme.settings.Settings; +import fr.xephi.authme.settings.properties.CommonSettings; import fr.xephi.authme.settings.properties.EmailSettings; -import fr.xephi.authme.settings.properties.PluginSettings; import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.util.FileUtils; import org.apache.commons.mail.EmailException; @@ -184,7 +184,7 @@ private static String embedImageIntoEmailContent(File image, HtmlEmail email, St private String replaceTagsForPasswordMail(String mailText, String name, String newPass, String ip, String time) { return mailText .replace("", name) - .replace("", settings.getProperty(PluginSettings.SERVER_NAME)) + .replace("", settings.getProperty(CommonSettings.SERVER_NAME)) .replace("", newPass) .replace("", ip) .replace("