diff --git a/docs/config.md b/docs/config.md index 95e1de39..10980d8a 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,5 @@ - + ## AuthMe Configuration The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, @@ -99,7 +99,8 @@ settings: # Should the session expire if the player tries to log in with # another IP address? sessionExpireOnIpChange: true - # Message language, available: en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt + # Message language, available languages: + # https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md messagesLanguage: 'en' restrictions: # Keeps collisions disabled for logged players @@ -131,9 +132,9 @@ settings: # This setting will prevent potential security exploits. ForceSingleSession: true ForceSpawnLocOnJoin: - # If enabled, every player that spawn in one of the world listed in "ForceSpawnLocOnJoin.worlds" - # will be teleported to the spawnpoint after successful authentication. - # The quit location of the player will be overwritten. + # If enabled, every player that spawn in one of the world listed in + # "ForceSpawnLocOnJoin.worlds" will be teleported to the spawnpoint after successful + # authentication. The quit location of the player will be overwritten. # This is different from "teleportUnAuthedToSpawn" that teleport player # to the spawnpoint on join. enabled: false @@ -202,8 +203,8 @@ settings: # FINE for some additional detailed ones (like password failed), # and DEBUG for debugging logLevel: 'FINE' - # 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 + # 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 useAsyncTasks: true GameMode: # Force survival gamemode when player joins? @@ -277,19 +278,23 @@ settings: forceLoginAfterRegister: false # Force these commands after /login, without any '/', use %p to replace with player name forceCommands: [] - # Force these commands after /login as service console, without any '/'. Use %p to replace with player name + # Force these commands after /login as service console, without any '/'. + # Use %p to replace with player name forceCommandsAsConsole: [] # Force these commands after /register, without any '/', use %p to replace with player name forceRegisterCommands: [] - # Force these commands after /register as a server console, without any '/'. Use %p to replace with player name + # Force these commands after /register as a server console, without any '/'. + # Use %p to replace with player name forceRegisterCommandsAsConsole: [] # Enable to display the welcome message (welcome.txt) after 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 + # {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 useWelcomeMessage: true - # Do we need to broadcast the welcome message to all server or only to the player? set true for server or false for player + # Broadcast the welcome message to the server or only to the player? + # set true for server or false for player broadcastWelcomeMessage: false # Should we delay the join message and display it once the player has logged in? delayJoinMessage: false @@ -361,7 +366,8 @@ Protection: enableProtection: false # Apply the protection also to registered usernames enableProtectionRegistered: true - # Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes + # Countries allowed to join the server and register. For country codes, see + # http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ # PLEASE USE QUOTES! countries: - 'US' @@ -372,7 +378,8 @@ Protection: - 'A1' # Do we need to enable automatic antibot system? enableAntiBot: true - # Max number of players allowed to login in 5 secs before the AntiBot system is enabled automatically + # Max number of players allowed to login in 5 secs + # before the AntiBot system is enabled automatically antiBotSensibility: 10 # Duration in minutes of the antibot automatic system antiBotDuration: 10 @@ -381,7 +388,7 @@ Protection: Purge: # If enabled, AuthMe automatically purges old, unused accounts useAutoPurge: false - # Number of Days an account become Unused + # Number of days after which an account should be purged daysBeforeRemovePlayer: 60 # Do we need to remove the player.dat file during purge process? removePlayerDat: false @@ -389,7 +396,7 @@ Purge: removeEssentialsFile: false # World where are players.dat stores defaultWorld: 'world' - # Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ? + # Remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge? removeLimitedCreativesInventories: false # Do we need to remove the AntiXRayData/PlayerData/player file during purge process? removeAntiXRayFile: false @@ -448,4 +455,4 @@ To change settings on a running server, save your changes to config.yml and use --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 23 18:25:12 CEST 2016 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 23 21:08:57 CEST 2016 diff --git a/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java b/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java index bfb56533..094a3d5b 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/PluginSettings.java @@ -36,7 +36,10 @@ public class PluginSettings implements SettingsHolder { public static final Property 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") + @Comment({ + "Message language, available languages:", + "https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md" + }) public static final Property MESSAGES_LANGUAGE = newProperty("settings.messagesLanguage", "en"); @@ -65,8 +68,8 @@ public class PluginSettings implements SettingsHolder { 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" + "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); diff --git a/src/main/java/fr/xephi/authme/settings/properties/ProtectionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/ProtectionSettings.java index cdd760bd..834b7dd9 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/ProtectionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/ProtectionSettings.java @@ -20,13 +20,16 @@ public class ProtectionSettings implements SettingsHolder { public static final Property ENABLE_PROTECTION_REGISTERED = newProperty("Protection.enableProtectionRegistered", true); - @Comment({"Countries allowed to join the server and register, see http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/ for countries' codes", - "PLEASE USE QUOTES!"}) + @Comment({ + "Countries allowed to join the server and register. For country codes, see", + "http://dev.bukkit.org/bukkit-plugins/authme-reloaded/pages/countries-codes/", + "PLEASE USE QUOTES!"}) public static final Property> COUNTRIES_WHITELIST = newListProperty("Protection.countries", "US", "GB"); - @Comment({"Countries not allowed to join the server and register", - "PLEASE USE QUOTES!"}) + @Comment({ + "Countries not allowed to join the server and register", + "PLEASE USE QUOTES!"}) public static final Property> COUNTRIES_BLACKLIST = newListProperty("Protection.countriesBlacklist", "A1"); @@ -34,7 +37,9 @@ public class ProtectionSettings implements SettingsHolder { public static final Property ENABLE_ANTIBOT = newProperty("Protection.enableAntiBot", true); - @Comment("Max number of players allowed to login in 5 secs before the AntiBot system is enabled automatically") + @Comment({ + "Max number of players allowed to login in 5 secs", + "before the AntiBot system is enabled automatically"}) public static final Property ANTIBOT_SENSIBILITY = newProperty("Protection.antiBotSensibility", 10); diff --git a/src/main/java/fr/xephi/authme/settings/properties/PurgeSettings.java b/src/main/java/fr/xephi/authme/settings/properties/PurgeSettings.java index f23a3eb1..b3733b5a 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/PurgeSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/PurgeSettings.java @@ -12,7 +12,7 @@ public class PurgeSettings implements SettingsHolder { public static final Property USE_AUTO_PURGE = newProperty("Purge.useAutoPurge", false); - @Comment("Number of Days an account become Unused") + @Comment("Number of days after which an account should be purged") public static final Property DAYS_BEFORE_REMOVE_PLAYER = newProperty("Purge.daysBeforeRemovePlayer", 60); @@ -28,7 +28,7 @@ public class PurgeSettings implements SettingsHolder { public static final Property DEFAULT_WORLD = newProperty("Purge.defaultWorld", "world"); - @Comment("Do we need to remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge process ?") + @Comment("Remove LimitedCreative/inventories/player.yml, player_creative.yml files during purge?") public static final Property REMOVE_LIMITED_CREATIVE_INVENTORIES = newProperty("Purge.removeLimitedCreativesInventories", false); diff --git a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java index b593869a..487039ba 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RegistrationSettings.java @@ -52,8 +52,9 @@ public class RegistrationSettings implements SettingsHolder { public static final Property> FORCE_COMMANDS = newListProperty("settings.forceCommands"); - @Comment("Force these commands after /login as service console, without any '/'. " - + "Use %p to replace with player name") + @Comment({ + "Force these commands after /login as service console, without any '/'.", + "Use %p to replace with player name"}) public static final Property> FORCE_COMMANDS_AS_CONSOLE = newListProperty("settings.forceCommandsAsConsole"); @@ -61,22 +62,25 @@ public class RegistrationSettings implements SettingsHolder { public static final Property> FORCE_REGISTER_COMMANDS = newListProperty("settings.forceRegisterCommands"); - @Comment("Force these commands after /register as a server console, without any '/'. " - + "Use %p to replace with player name") + @Comment({ + "Force these commands after /register as a server console, without any '/'.", + "Use %p to replace with player name"}) public static final Property> FORCE_REGISTER_COMMANDS_AS_CONSOLE = newListProperty("settings.forceRegisterCommandsAsConsole"); @Comment({ "Enable to display the welcome message (welcome.txt) after 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", + "{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 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") + @Comment({ + "Broadcast the welcome message to the server or only to the player?", + "set true for server or false for player"}) public static final Property BROADCAST_WELCOME_MESSAGE = newProperty("settings.broadcastWelcomeMessage", false); diff --git a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java index 9e16714d..4cd321f6 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/RestrictionSettings.java @@ -50,9 +50,9 @@ public class RestrictionSettings implements SettingsHolder { newProperty("settings.restrictions.ForceSingleSession", true); @Comment({ - "If enabled, every player that spawn in one of the world listed in \"ForceSpawnLocOnJoin.worlds\"", - "will be teleported to the spawnpoint after successful authentication.", - "The quit location of the player will be overwritten.", + "If enabled, every player that spawn in one of the world listed in", + "\"ForceSpawnLocOnJoin.worlds\" will be teleported to the spawnpoint after successful", + "authentication. The quit location of the player will be overwritten.", "This is different from \"teleportUnAuthedToSpawn\" that teleport player", "to the spawnpoint on join."}) public static final Property FORCE_SPAWN_LOCATION_AFTER_LOGIN = diff --git a/src/test/java/fr/xephi/authme/settings/SettingsConsistencyTest.java b/src/test/java/fr/xephi/authme/settings/SettingsConsistencyTest.java new file mode 100644 index 00000000..7123ac26 --- /dev/null +++ b/src/test/java/fr/xephi/authme/settings/SettingsConsistencyTest.java @@ -0,0 +1,69 @@ +package fr.xephi.authme.settings; + +import com.github.authme.configme.knownproperties.ConfigurationData; +import com.github.authme.configme.properties.Property; +import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static org.junit.Assert.fail; + +/** + * Tests the consistency of the settings configuration. + */ +public class SettingsConsistencyTest { + + /** + * Maximum characters one comment line may have (prevents horizontal scrolling). + */ + private static final int MAX_COMMENT_LENGTH = 90; + + private static ConfigurationData configurationData; + + @BeforeClass + public static void buildConfigurationData() { + configurationData = AuthMeSettingsRetriever.buildConfigurationData(); + } + + @Test + public void shouldHaveCommentOnEachProperty() { + // given + List> properties = configurationData.getProperties(); + + // when / then + for (Property property : properties) { + if (configurationData.getCommentsForSection(property.getPath()).length == 0) { + fail("No comment defined for '" + property + "'"); + } + } + } + + @Test + public void shouldNotHaveVeryLongCommentLines() { + // given + List> properties = configurationData.getProperties(); + List> badProperties = new ArrayList<>(); + + // when + for (Property property : properties) { + for (String comment : configurationData.getCommentsForSection(property.getPath())) { + if (comment.length() > MAX_COMMENT_LENGTH) { + badProperties.add(property); + break; + } + } + } + + // then + if (!badProperties.isEmpty()) { + fail("Comment lines should not be longer than " + MAX_COMMENT_LENGTH + " chars, " + + "but found too long comments for:\n- " + + badProperties.stream().map(Property::getPath).collect(Collectors.joining("\n- "))); + } + } + +}