Implemented getemail command

Various other improvements.
This commit is contained in:
Tim Visée 2015-11-01 18:02:26 +01:00
parent 89c3c6ed5b
commit 19f4af3e85
6 changed files with 64 additions and 0 deletions

View File

@ -164,6 +164,21 @@ public class CommandManager {
accountsCommand.setCommandPermissions("authme.admin.accounts", CommandPermissions.DefaultPermission.OP_ONLY); accountsCommand.setCommandPermissions("authme.admin.accounts", CommandPermissions.DefaultPermission.OP_ONLY);
accountsCommand.addArgument(new CommandArgumentDescription("player", "Player name or IP", true)); accountsCommand.addArgument(new CommandArgumentDescription("player", "Player name or IP", true));
// Register the getemail command
CommandDescription getEmailCommand = new CommandDescription(
new RegisterCommand(),
new ArrayList<String>() {{
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 // Register the purge command
CommandDescription purgeCommand = new CommandDescription( CommandDescription purgeCommand = new CommandDescription(
new PurgeCommand(), new PurgeCommand(),

View File

@ -25,6 +25,7 @@ public class AccountsCommand extends ExecutableCommand {
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance
final AuthMe plugin = AuthMe.getInstance(); final AuthMe plugin = AuthMe.getInstance();
// Messages instance // Messages instance
final Messages m = Messages.getInstance(); final Messages m = Messages.getInstance();

View File

@ -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;
}
}

View File

@ -24,6 +24,7 @@ public class LastLoginCommand extends ExecutableCommand {
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance
AuthMe plugin = AuthMe.getInstance(); AuthMe plugin = AuthMe.getInstance();
// Messages instance // Messages instance
Messages m = Messages.getInstance(); Messages m = Messages.getInstance();

View File

@ -28,6 +28,7 @@ public class RegisterCommand extends ExecutableCommand {
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance
final AuthMe plugin = AuthMe.getInstance(); final AuthMe plugin = AuthMe.getInstance();
// Messages instance // Messages instance
final Messages m = Messages.getInstance(); final Messages m = Messages.getInstance();

View File

@ -29,6 +29,7 @@ public class ReloadCommand extends ExecutableCommand {
// AuthMe plugin instance // AuthMe plugin instance
AuthMe plugin = AuthMe.getInstance(); AuthMe plugin = AuthMe.getInstance();
// Messages instance // Messages instance
Messages m = Messages.getInstance(); Messages m = Messages.getInstance();