diff --git a/src/main/java/fr/xephi/authme/command/CommandInitializer.java b/src/main/java/fr/xephi/authme/command/CommandInitializer.java index 9381499c..b3db5c1c 100644 --- a/src/main/java/fr/xephi/authme/command/CommandInitializer.java +++ b/src/main/java/fr/xephi/authme/command/CommandInitializer.java @@ -1,5 +1,6 @@ package fr.xephi.authme.command; +import com.google.common.collect.ImmutableSet; import fr.xephi.authme.command.executable.HelpCommand; import fr.xephi.authme.command.executable.authme.AccountsCommand; import fr.xephi.authme.command.executable.authme.AuthMeCommand; @@ -37,6 +38,7 @@ import fr.xephi.authme.util.Wrapper; import java.util.*; +import static com.google.common.collect.Sets.newHashSet; import static fr.xephi.authme.permission.DefaultPermission.ALLOWED; import static fr.xephi.authme.permission.DefaultPermission.OP_ONLY; @@ -495,7 +497,7 @@ public final class CommandInitializer { .build(); // Add the base commands to the commands array - baseCommands = new HashSet<>(Arrays.asList( + baseCommands = ImmutableSet.of( AUTHME_BASE, LOGIN_BASE, LOGOUT_BASE, @@ -504,6 +506,6 @@ public final class CommandInitializer { CHANGE_PASSWORD_BASE, EMAIL_BASE, CAPTCHA_BASE, - CONVERTER_BASE)); + CONVERTER_BASE); } } diff --git a/src/main/java/fr/xephi/authme/command/CommandParts.java b/src/main/java/fr/xephi/authme/command/CommandParts.java deleted file mode 100644 index b34df6b1..00000000 --- a/src/main/java/fr/xephi/authme/command/CommandParts.java +++ /dev/null @@ -1,70 +0,0 @@ -package fr.xephi.authme.command; - -import fr.xephi.authme.util.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - */ -public class CommandParts { - - /** - * The list of parts for this command. - */ - private final List parts = new ArrayList<>(); - - /** - * Constructor. - * - * @param part The part to add. - */ - public CommandParts(String part) { - this.parts.add(part); - } - - /** - * Constructor. - * - * @param parts The list of parts. - */ - public CommandParts(List parts) { - this.parts.addAll(parts); - } - - /** - * Get the command parts. - * - * @return Command parts. - */ - public List getList() { - return this.parts; - } - - /** - * Get a part by its index. - * - * @param i Part index. - * - * @return The part. - */ - public String get(int i) { - // Make sure the index is in-bound - if (i < 0 || i >= parts.size()) { - return null; - } - - // Get and return the argument - return this.parts.get(i); - } - - /** - * Convert the parts to a string. - * - * @return The part as a string. - */ - @Override - public String toString() { - return StringUtils.join(" ", this.parts); - } -} diff --git a/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java b/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java index d8982fa9..ff7a9130 100644 --- a/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/HelpCommand.java @@ -1,6 +1,5 @@ package fr.xephi.authme.command.executable; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.help.HelpProvider; import org.bukkit.command.CommandSender; diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java index ec78d908..3cd42839 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/AuthMeCommand.java @@ -7,14 +7,18 @@ import org.bukkit.command.CommandSender; import java.util.List; +/** + * AuthMe base command; shows the version and some command pointers. + */ public class AuthMeCommand extends ExecutableCommand { @Override public void executeCommand(CommandSender sender, List arguments) { - // Show some version info - // FIXME replace use of commandReference - sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v" + AuthMe.getPluginVersion() + " b" + AuthMe.getPluginBuildNumber()+ "! " + ChatColor.RED + "<3"); - sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " help" + ChatColor.YELLOW + " to view help."); - sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about."); + sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v" + + AuthMe.getPluginVersion() + " b" + AuthMe.getPluginBuildNumber()+ "! " + ChatColor.RED + "<3"); + sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/authme help" + ChatColor.YELLOW + + " to view help."); + sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/authme about" + ChatColor.YELLOW + + " to view about."); } } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java index b3ea9a2c..590db3d8 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterAdminCommand.java @@ -3,7 +3,6 @@ package fr.xephi.authme.command.executable.authme; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; @@ -13,23 +12,15 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import java.security.NoSuchAlgorithmException; +import java.util.List; /** * Admin command to register a user. */ public class RegisterAdminCommand extends ExecutableCommand { - /** - * Execute the command. - * - * @param sender The command sender. - * @param commandReference The command reference. - * @param commandArguments The command arguments. - * - * @return True if the command was executed successfully, false otherwise. - */ @Override - public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { + public void executeCommand(final CommandSender sender, List arguments) { // AuthMe plugin instance final AuthMe plugin = AuthMe.getInstance(); @@ -37,8 +28,8 @@ public class RegisterAdminCommand extends ExecutableCommand { final Messages m = plugin.getMessages(); // Get the player name and password - final String playerName = commandArguments.get(0); - final String playerPass = commandArguments.get(1); + final String playerName = arguments.get(0); + final String playerPass = arguments.get(1); final String playerNameLowerCase = playerName.toLowerCase(); final String playerPassLowerCase = playerPass.toLowerCase(); @@ -49,20 +40,20 @@ public class RegisterAdminCommand extends ExecutableCommand { || playerPassLowerCase.contains(";") || playerPassLowerCase.contains("null") || !playerPassLowerCase.matches(Settings.getPassRegex)) { m.send(sender, MessageKey.PASSWORD_MATCH_ERROR); - return true; + return; } if (playerPassLowerCase.equalsIgnoreCase(playerName)) { m.send(sender, MessageKey.PASSWORD_IS_USERNAME_ERROR); - return true; + return; } if (playerPassLowerCase.length() < Settings.getPasswordMinLen || playerPassLowerCase.length() > Settings.passwordMaxLength) { m.send(sender, MessageKey.INVALID_PASSWORD_LENGTH); - return true; + return; } if (!Settings.unsafePasswords.isEmpty()) { if (Settings.unsafePasswords.contains(playerPassLowerCase)) { m.send(sender, MessageKey.PASSWORD_UNSAFE_ERROR); - return true; + return; } } plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { @@ -95,6 +86,5 @@ public class RegisterAdminCommand extends ExecutableCommand { } }); - return true; } } diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java deleted file mode 100644 index ae1f3840..00000000 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ResetNameCommand.java +++ /dev/null @@ -1,44 +0,0 @@ -package fr.xephi.authme.command.executable.authme; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.command.CommandParts; -import fr.xephi.authme.command.ExecutableCommand; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; - -import java.util.List; - -/** - */ -public class ResetNameCommand extends ExecutableCommand { - - /** - * Execute the command. - * - * @param sender The command sender. - * @param commandReference The command reference. - * @param commandArguments The command arguments. - * - * @return True if the command was executed successfully, false otherwise. - */ - @Override - public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { - // AuthMe plugin instance - final AuthMe plugin = AuthMe.getInstance(); - - // Command logic - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - @Override - public void run() { - List authentications = plugin.database.getAllAuths(); - for (PlayerAuth auth : authentications) { - auth.setRealName("Player"); - plugin.database.updateSession(auth); - } - } - }); - - return true; - } -} diff --git a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java index e45b4186..fa683524 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java @@ -12,7 +12,6 @@ import org.bukkit.entity.Player; import fr.xephi.authme.AuthMe; import fr.xephi.authme.command.CommandArgumentDescription; import fr.xephi.authme.command.CommandDescription; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandPermissions; import fr.xephi.authme.permission.PermissionNode; import fr.xephi.authme.util.CollectionUtils; diff --git a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java index 44afbefa..501a8426 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpProvider.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpProvider.java @@ -2,7 +2,6 @@ package fr.xephi.authme.command.help; import fr.xephi.authme.AuthMe; import fr.xephi.authme.command.CommandDescription; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandUtils; import fr.xephi.authme.command.FoundCommandResult; import fr.xephi.authme.settings.Settings; diff --git a/src/main/java/fr/xephi/authme/command/help/HelpSyntaxHelper.java b/src/main/java/fr/xephi/authme/command/help/HelpSyntaxHelper.java index 6d1b1d7d..cc7a7d6e 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpSyntaxHelper.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpSyntaxHelper.java @@ -2,7 +2,6 @@ package fr.xephi.authme.command.help; import fr.xephi.authme.command.CommandArgumentDescription; import fr.xephi.authme.command.CommandDescription; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandUtils; import fr.xephi.authme.util.CollectionUtils; import fr.xephi.authme.util.StringUtils; diff --git a/src/test/java/fr/xephi/authme/command/executable/captcha/CaptchaCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/captcha/CaptchaCommandTest.java index 6b183e35..4a8af38d 100644 --- a/src/test/java/fr/xephi/authme/command/executable/captcha/CaptchaCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/captcha/CaptchaCommandTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.command.executable.captcha; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; diff --git a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java index 5c9c295c..da8f82ce 100644 --- a/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/changepassword/ChangePasswordCommandTest.java @@ -3,7 +3,6 @@ package fr.xephi.authme.command.executable.changepassword; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ReflectionTestUtils; import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; import fr.xephi.authme.settings.Settings; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java index d377fc0f..38c7d046 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/AddEmailCommandTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.command.executable.email; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.process.Management; import fr.xephi.authme.util.WrapperMock; import org.bukkit.command.BlockCommandSender; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java index 2dc25c96..183f3ad1 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/ChangeEmailCommandTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.command.executable.email; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.process.Management; import fr.xephi.authme.util.WrapperMock; import org.bukkit.command.BlockCommandSender; diff --git a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java index a1403c5a..73711de9 100644 --- a/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/email/RecoverEmailCommandTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.command.executable.email; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.util.WrapperMock; import org.bukkit.command.BlockCommandSender; import org.bukkit.command.CommandSender; diff --git a/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java index 52a71891..4e6c268d 100644 --- a/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/login/LoginCommandTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.command.executable.login; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.process.Management; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.util.WrapperMock; diff --git a/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java index 65f24639..82ffd1a7 100644 --- a/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/logout/LogoutCommandTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.command.executable.logout; import fr.xephi.authme.AuthMe; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.process.Management; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.util.WrapperMock; diff --git a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java index 6dd19eb2..cbc12369 100644 --- a/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java +++ b/src/test/java/fr/xephi/authme/command/executable/register/RegisterCommandTest.java @@ -1,6 +1,5 @@ package fr.xephi.authme.command.executable.register; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.process.Management; import fr.xephi.authme.output.MessageKey; import fr.xephi.authme.output.Messages; diff --git a/src/test/java/fr/xephi/authme/command/help/HelpSyntaxHelperTest.java b/src/test/java/fr/xephi/authme/command/help/HelpSyntaxHelperTest.java index 3ca665f4..185bf08b 100644 --- a/src/test/java/fr/xephi/authme/command/help/HelpSyntaxHelperTest.java +++ b/src/test/java/fr/xephi/authme/command/help/HelpSyntaxHelperTest.java @@ -1,7 +1,6 @@ package fr.xephi.authme.command.help; import fr.xephi.authme.command.CommandDescription; -import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.executable.authme.RegisterAdminCommand; import org.junit.Test;