diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/CountryLookup.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/CountryLookup.java index 6e126b905..78cee4622 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/CountryLookup.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/CountryLookup.java @@ -42,6 +42,7 @@ class CountryLookup implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { + sender.sendMessage(ChatColor.BLUE + "AuthMe country lookup"); if (arguments.isEmpty()) { sender.sendMessage("Check player: /authme debug cty Bobby"); sender.sendMessage("Check IP address: /authme debug cty 127.123.45.67"); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DataStatistics.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DataStatistics.java index 22ee211f1..75a17869c 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DataStatistics.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DataStatistics.java @@ -10,6 +10,7 @@ import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.factory.SingletonStore; import fr.xephi.authme.permission.DebugSectionPermissions; import fr.xephi.authme.permission.PermissionNode; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import javax.inject.Inject; @@ -47,6 +48,7 @@ class DataStatistics implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { + sender.sendMessage(ChatColor.BLUE + "AuthMe statistics"); sender.sendMessage("LimboPlayers in memory: " + applyToLimboPlayersMap(limboService, Map::size)); sender.sendMessage("PlayerCache size: " + playerCache.getLogged() + " (= logged in players)"); @@ -68,11 +70,10 @@ class DataStatistics implements DebugSection { } private void outputInjectorStats(CommandSender sender) { - sender.sendMessage( - String.format("Singleton Java classes: %d (Reloadable: %d / SettingsDependent: %d / HasCleanup: %d)", - singletonStore.retrieveAllOfType().size(), - singletonStore.retrieveAllOfType(Reloadable.class).size(), - singletonStore.retrieveAllOfType(SettingsDependent.class).size(), - singletonStore.retrieveAllOfType(HasCleanup.class).size())); + sender.sendMessage("Singleton Java classes: " + singletonStore.retrieveAllOfType().size()); + sender.sendMessage(String.format("(Reloadable: %d / SettingsDependent: %d / HasCleanup: %d)", + singletonStore.retrieveAllOfType(Reloadable.class).size(), + singletonStore.retrieveAllOfType(SettingsDependent.class).size(), + singletonStore.retrieveAllOfType(HasCleanup.class).size())); } } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java index d6c4e2f43..53ee747e8 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/DebugCommand.java @@ -49,6 +49,7 @@ public class DebugCommand implements ExecutableCommand { } private void sendAvailableSections(CommandSender sender) { + sender.sendMessage(ChatColor.BLUE + "AuthMe debug utils"); sender.sendMessage("Sections available to you:"); long availableSections = getSections().values().stream() .filter(section -> permissionsManager.hasPermission(sender, section.getRequiredPermission())) diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionChecker.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionChecker.java index a35fe2219..e8a15b795 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionChecker.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/HasPermissionChecker.java @@ -42,11 +42,12 @@ class HasPermissionChecker implements DebugSection { @Override public String getDescription() { - return "Checks if player has given permission: /authme debug perm bobby my.perm"; + return "Checks if a player has a given permission"; } @Override public void execute(CommandSender sender, List arguments) { + sender.sendMessage(ChatColor.BLUE + "AuthMe permission check"); if (arguments.size() < 2) { sender.sendMessage("Check if a player has permission:"); sender.sendMessage("Example: /authme debug perm bobby my.perm.node"); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/InputValidator.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/InputValidator.java index d1131e0ae..2e82c3c82 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/InputValidator.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/InputValidator.java @@ -40,7 +40,7 @@ class InputValidator implements DebugSection { @Override public String getDescription() { - return "Check if email / password is valid according to your settings"; + return "Checks if your config.yml allows a password / email"; } @Override @@ -68,16 +68,18 @@ class InputValidator implements DebugSection { } private void displayUsageHint(CommandSender sender) { - sender.sendMessage("You can define forbidden emails and passwords in your config.yml"); - sender.sendMessage("This command allows you to test some of the values:"); - sender.sendMessage("/authme debug valid pass test1234 -- test if 'test1234' is allowed password"); - sender.sendMessage("/authme debug valid mail t@t.tld -- test if 't@t.tld' is allowed email"); - sender.sendMessage("/authme debug valid name bobby1 -- test if 'bobby1' is allowed username"); + sender.sendMessage(ChatColor.BLUE + "Validation tests"); + sender.sendMessage("You can define forbidden emails and passwords in your config.yml." + + " You can test your settings with this command."); + final String command = ChatColor.GOLD + "/authme debug valid"; + sender.sendMessage(" Use " + command + " pass " + ChatColor.RESET + " to check a password"); + sender.sendMessage(" Use " + command + " mail " + ChatColor.RESET + " to check an email"); + sender.sendMessage(" Use " + command + " name " + ChatColor.RESET + " to check a username"); } private void validatePassword(CommandSender sender, String password) { ValidationResult validationResult = validationService.validatePassword(password, ""); - sender.sendMessage("Validation of password '" + password + "' returned:"); + sender.sendMessage(ChatColor.BLUE + "Validation of password '" + password + "'"); if (validationResult.hasError()) { messages.send(sender, validationResult.getMessageKey(), validationResult.getArgs()); } else { @@ -87,7 +89,7 @@ class InputValidator implements DebugSection { private void validateEmail(CommandSender sender, String email) { boolean isValidEmail = validationService.validateEmail(email); - sender.sendMessage("Validation of email '" + email + "' returned:"); + sender.sendMessage(ChatColor.BLUE + "Validation of email '" + email + "'"); if (isValidEmail) { sender.sendMessage(ChatColor.DARK_GREEN + "Valid email!"); } else { @@ -96,7 +98,7 @@ class InputValidator implements DebugSection { } private void validateUsername(CommandSender sender, String username) { - sender.sendMessage("Validation of username '" + username + "' returned:"); + sender.sendMessage(ChatColor.BLUE + "Validation of username '" + username + "'"); try { onJoinVerifier.checkIsValidName(username); sender.sendMessage("Valid username!"); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/LimboPlayerViewer.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/LimboPlayerViewer.java index 6633c1c02..8be10c5f2 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/LimboPlayerViewer.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/LimboPlayerViewer.java @@ -50,6 +50,7 @@ class LimboPlayerViewer implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { if (arguments.isEmpty()) { + sender.sendMessage(ChatColor.BLUE + "AuthMe limbo viewer"); sender.sendMessage("/authme debug limbo : show a player's limbo info"); sender.sendMessage("Available limbo records: " + applyToLimboPlayersMap(limboService, Map::keySet)); return; @@ -59,11 +60,12 @@ class LimboPlayerViewer implements DebugSection { Player player = bukkitService.getPlayerExact(arguments.get(0)); LimboPlayer diskLimbo = player != null ? limboPersistence.getLimboPlayer(player) : null; if (memoryLimbo == null && player == null) { - sender.sendMessage("No limbo info and no player online with name '" + arguments.get(0) + "'"); + sender.sendMessage(ChatColor.BLUE + "No AuthMe limbo data"); + sender.sendMessage("No limbo data and no player online with name '" + arguments.get(0) + "'"); return; } - sender.sendMessage(ChatColor.GOLD + "Showing player / limbo / disk limbo info for '" + arguments.get(0) + "'"); + sender.sendMessage(ChatColor.BLUE + "Player / limbo / disk limbo info for '" + arguments.get(0) + "'"); new InfoDisplayer(sender, player, memoryLimbo, diskLimbo) .sendEntry("Is op", Player::isOp, LimboPlayer::isOperator) .sendEntry("Walk speed", Player::getWalkSpeed, LimboPlayer::getWalkSpeed) diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChanger.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChanger.java index f13cd5cf3..5fbd6993f 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChanger.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/MySqlDefaultChanger.java @@ -63,7 +63,7 @@ class MySqlDefaultChanger implements DebugSection { @Override public String getDescription() { - return "Add or remove the default value of a column for MySQL"; + return "Add or remove the default value of MySQL columns"; } @Override @@ -85,6 +85,7 @@ class MySqlDefaultChanger implements DebugSection { } else if (operation == null || column == null) { displayUsageHints(sender); } else { + sender.sendMessage(ChatColor.BLUE + "[AuthMe] MySQL change '" + column + "'"); try (Connection con = getConnection(mySql)) { switch (operation) { case ADD: @@ -172,6 +173,7 @@ class MySqlDefaultChanger implements DebugSection { } private void showColumnDetails(CommandSender sender) { + sender.sendMessage(ChatColor.BLUE + "MySQL column details"); final String tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE); try (Connection con = getConnection(mySql)) { final DatabaseMetaData metaData = con.getMetaData(); @@ -196,6 +198,7 @@ class MySqlDefaultChanger implements DebugSection { * @param sender the sender issuing the command */ private void displayUsageHints(CommandSender sender) { + sender.sendMessage(ChatColor.BLUE + "MySQL column changer"); sender.sendMessage("Adds or removes a NOT NULL constraint for a column."); sender.sendMessage("Examples: add a NOT NULL constraint with"); sender.sendMessage(" /authme debug mysqldef add "); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PermissionGroups.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PermissionGroups.java index 0fd62d8d3..72965601e 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PermissionGroups.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PermissionGroups.java @@ -4,6 +4,7 @@ import fr.xephi.authme.permission.DebugSectionPermissions; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.permission.PermissionsManager; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -30,6 +31,7 @@ class PermissionGroups implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { + sender.sendMessage(ChatColor.BLUE + "AuthMe permission groups"); String name = arguments.isEmpty() ? sender.getName() : arguments.get(0); Player player = Bukkit.getPlayer(name); if (player == null) { diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java index b16a2f574..07e160a40 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/PlayerAuthViewer.java @@ -39,6 +39,7 @@ class PlayerAuthViewer implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { if (arguments.isEmpty()) { + sender.sendMessage(ChatColor.BLUE + "AuthMe database viewer"); sender.sendMessage("Enter player name to view his data in the database."); sender.sendMessage("Example: /authme debug db Bobby"); return; @@ -46,6 +47,7 @@ class PlayerAuthViewer implements DebugSection { PlayerAuth auth = dataSource.getAuth(arguments.get(0)); if (auth == null) { + sender.sendMessage(ChatColor.BLUE + "AuthMe database viewer"); sender.sendMessage("No record exists for '" + arguments.get(0) + "'"); } else { displayAuthToSender(auth, sender); @@ -64,7 +66,7 @@ class PlayerAuthViewer implements DebugSection { * @param sender the sender to send the messages to */ private void displayAuthToSender(PlayerAuth auth, CommandSender sender) { - sender.sendMessage(ChatColor.GOLD + "[AuthMe] Player " + auth.getNickname() + " / " + auth.getRealName()); + sender.sendMessage(ChatColor.BLUE + "[AuthMe] Player " + auth.getNickname() + " / " + auth.getRealName()); sender.sendMessage("Email: " + auth.getEmail() + ". IP: " + auth.getLastIp() + ". Group: " + auth.getGroupId()); sender.sendMessage("Quit location: " + formatLocation(auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld())); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/SpawnLocationViewer.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/SpawnLocationViewer.java index cfb6e0cd0..30f756c32 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/SpawnLocationViewer.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/SpawnLocationViewer.java @@ -6,6 +6,7 @@ import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.SpawnLoader; import fr.xephi.authme.settings.properties.RestrictionSettings; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -42,6 +43,7 @@ class SpawnLocationViewer implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { + sender.sendMessage(ChatColor.BLUE + "AuthMe spawn location viewer"); if (arguments.isEmpty()) { showGeneralInfo(sender); } else if ("?".equals(arguments.get(0))) { diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/debug/TestEmailSender.java b/src/main/java/fr/xephi/authme/command/executable/authme/debug/TestEmailSender.java index b57a5d6ae..f3580d326 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/debug/TestEmailSender.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/debug/TestEmailSender.java @@ -44,6 +44,7 @@ class TestEmailSender implements DebugSection { @Override public void execute(CommandSender sender, List arguments) { + sender.sendMessage(ChatColor.BLUE + "AuthMe test email sender"); if (!sendMailSsl.hasAllInformation()) { sender.sendMessage(ChatColor.RED + "You haven't set all required configurations in config.yml " + "for sending emails. Please check your config.yml"); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java index dee5bdb7b..e28c110fa 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DataStatisticsTest.java @@ -12,6 +12,7 @@ import fr.xephi.authme.initialization.HasCleanup; import fr.xephi.authme.initialization.Reloadable; import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.factory.SingletonStore; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.junit.Before; import org.junit.Test; @@ -80,7 +81,9 @@ public class DataStatisticsTest { ArgumentCaptor stringCaptor = ArgumentCaptor.forClass(String.class); verify(sender, atLeastOnce()).sendMessage(stringCaptor.capture()); assertThat(stringCaptor.getAllValues(), containsInAnyOrder( - "Singleton Java classes: 7 (Reloadable: 4 / SettingsDependent: 3 / HasCleanup: 2)", + ChatColor.BLUE + "AuthMe statistics", + "Singleton Java classes: 7", + "(Reloadable: 4 / SettingsDependent: 3 / HasCleanup: 2)", "LimboPlayers in memory: 1", "Total players in DB: 219", "PlayerCache size: 12 (= logged in players)")); diff --git a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java index a87034441..3174926ad 100644 --- a/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/authme/debug/DebugCommandTest.java @@ -4,6 +4,7 @@ import fr.xephi.authme.initialization.factory.Factory; import fr.xephi.authme.permission.DebugSectionPermissions; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.permission.PermissionsManager; +import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.junit.Before; import org.junit.Test; @@ -85,11 +86,12 @@ public class DebugCommandTest { verify(permissionsManager, atLeast(MIN_DEBUG_SECTIONS)).hasPermission(eq(sender), any(DebugSectionPermissions.class)); ArgumentCaptor strCaptor = ArgumentCaptor.forClass(String.class); - verify(sender, times(3)).sendMessage(strCaptor.capture()); + verify(sender, times(4)).sendMessage(strCaptor.capture()); assertThat(strCaptor.getAllValues(), contains( - containsString("Sections available to you"), + equalTo(ChatColor.BLUE + "AuthMe debug utils"), + equalTo("Sections available to you:"), containsString("stats: Outputs general data statistics"), - containsString("valid: Check if email / password is valid"))); + containsString("valid: Checks if your config.yml allows a password / email"))); } @Test @@ -106,8 +108,9 @@ public class DebugCommandTest { verify(permissionsManager, atLeast(MIN_DEBUG_SECTIONS)).hasPermission(eq(sender), any(DebugSectionPermissions.class)); ArgumentCaptor strCaptor = ArgumentCaptor.forClass(String.class); - verify(sender, times(2)).sendMessage(strCaptor.capture()); + verify(sender, times(3)).sendMessage(strCaptor.capture()); assertThat(strCaptor.getAllValues(), contains( + equalTo(ChatColor.BLUE + "AuthMe debug utils"), equalTo("Sections available to you:"), containsString("You don't have permission to view any debug section"))); }