From 19f4af3e8554f975392e7e78d1d3a62da5b3cce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sun, 1 Nov 2015 18:02:26 +0100 Subject: [PATCH] Implemented getemail command Various other improvements. --- .../xephi/authme/command/CommandManager.java | 15 +++++++ .../executable/authme/AccountsCommand.java | 1 + .../executable/authme/GetEmailCommand.java | 45 +++++++++++++++++++ .../executable/authme/LastLoginCommand.java | 1 + .../executable/authme/RegisterCommand.java | 1 + .../executable/authme/ReloadCommand.java | 1 + 6 files changed, 64 insertions(+) create mode 100644 src/main/java/fr/xephi/authme/command/executable/authme/GetEmailCommand.java diff --git a/src/main/java/fr/xephi/authme/command/CommandManager.java b/src/main/java/fr/xephi/authme/command/CommandManager.java index 878ed7e02..bba25bcdd 100644 --- a/src/main/java/fr/xephi/authme/command/CommandManager.java +++ b/src/main/java/fr/xephi/authme/command/CommandManager.java @@ -164,6 +164,21 @@ public class CommandManager { accountsCommand.setCommandPermissions("authme.admin.accounts", CommandPermissions.DefaultPermission.OP_ONLY); accountsCommand.addArgument(new CommandArgumentDescription("player", "Player name or IP", true)); + // Register the getemail command + CommandDescription getEmailCommand = new CommandDescription( + new RegisterCommand(), + new ArrayList() {{ + add("getemail"); + add("getmail"); + add("email"); + add("mail"); + }}, + "Display player's email", + "Display the email address of the specified player if set.", + authMeCommand); + getEmailCommand.setCommandPermissions("authme.admin.getemail", CommandPermissions.DefaultPermission.OP_ONLY); + getEmailCommand.addArgument(new CommandArgumentDescription("player", "Player name", true)); + // Register the purge command CommandDescription purgeCommand = new CommandDescription( new PurgeCommand(), diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java index 3634d3f7f..fddf078a2 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/AccountsCommand.java @@ -25,6 +25,7 @@ public class AccountsCommand extends ExecutableCommand { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { // AuthMe plugin instance final AuthMe plugin = AuthMe.getInstance(); + // Messages instance final Messages m = Messages.getInstance(); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/GetEmailCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/GetEmailCommand.java new file mode 100644 index 000000000..76d5423cb --- /dev/null +++ b/src/main/java/fr/xephi/authme/command/executable/authme/GetEmailCommand.java @@ -0,0 +1,45 @@ +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 fr.xephi.authme.settings.Messages; +import org.bukkit.command.CommandSender; + +public class GetEmailCommand 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 + AuthMe plugin = AuthMe.getInstance(); + + // Messages instance + Messages m = Messages.getInstance(); + + // Get the player name + String playerName = sender.getName(); + if(commandArguments.getCount() >= 1) + playerName = commandArguments.get(0); + + // Get the authenticated user + PlayerAuth auth = plugin.database.getAuth(playerName.toLowerCase()); + if (auth == null) { + m.send(sender, "unknown_user"); + return true; + } + + // Show the email address + sender.sendMessage("[AuthMe] " + playerName + "'s email: " + auth.getEmail()); + return true; + } +} diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/LastLoginCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/LastLoginCommand.java index 6218ad0d5..121a4c152 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/LastLoginCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/LastLoginCommand.java @@ -24,6 +24,7 @@ public class LastLoginCommand extends ExecutableCommand { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { // AuthMe plugin instance AuthMe plugin = AuthMe.getInstance(); + // Messages instance Messages m = Messages.getInstance(); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterCommand.java index ee4d84948..782cc7875 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/RegisterCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/RegisterCommand.java @@ -28,6 +28,7 @@ public class RegisterCommand extends ExecutableCommand { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { // AuthMe plugin instance final AuthMe plugin = AuthMe.getInstance(); + // Messages instance final Messages m = Messages.getInstance(); diff --git a/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java b/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java index 4364e928e..1d1dea022 100644 --- a/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java +++ b/src/main/java/fr/xephi/authme/command/executable/authme/ReloadCommand.java @@ -29,6 +29,7 @@ public class ReloadCommand extends ExecutableCommand { // AuthMe plugin instance AuthMe plugin = AuthMe.getInstance(); + // Messages instance Messages m = Messages.getInstance();