mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-10-31 07:39:42 +01:00
Implemented the unregister command
This commit is contained in:
parent
ebefca73b7
commit
7f63056cc9
@ -351,7 +351,7 @@ public class AuthMe extends JavaPlugin {
|
||||
//getCommand("login").setExecutor(new LoginCommand(this));
|
||||
//getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
|
||||
//getCommand("logout").setExecutor(new LogoutCommand(this));
|
||||
getCommand("unregister").setExecutor(new UnregisterCommand(this));
|
||||
//getCommand("unregister").setExecutor(new UnregisterCommand(this));
|
||||
getCommand("email").setExecutor(new EmailCommand(this));
|
||||
getCommand("captcha").setExecutor(new CaptchaCommand(this));
|
||||
getCommand("converter").setExecutor(new ConverterCommand(this));
|
||||
|
@ -413,6 +413,35 @@ public class CommandManager {
|
||||
registerHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
registerHelpCommand.setMaximumArguments(false);
|
||||
|
||||
// Register the base unregister command
|
||||
CommandDescription unregisterBaseCommand = new CommandDescription(
|
||||
new RegisterCommand(),
|
||||
new ArrayList<String>() {{
|
||||
add("unregister");
|
||||
add("unreg");
|
||||
}},
|
||||
"Unregistration command",
|
||||
"Command to unregister using AuthMeReloaded.", null);
|
||||
unregisterBaseCommand.setCommandPermissions("authme.unregister", CommandPermissions.DefaultPermission.ALLOWED);
|
||||
unregisterBaseCommand.addArgument(new CommandArgumentDescription("password", "Password", false));
|
||||
unregisterBaseCommand.setMaximumArguments(false);
|
||||
|
||||
// Register the help command
|
||||
CommandDescription unregisterHelpCommand = new CommandDescription(
|
||||
new HelpCommand(),
|
||||
new ArrayList<String>() {{
|
||||
add("help");
|
||||
add("hlp");
|
||||
add("h");
|
||||
add("sos");
|
||||
add("?");
|
||||
}},
|
||||
"View help",
|
||||
"View detailed help pages about AuthMeReloaded register commands.",
|
||||
unregisterBaseCommand);
|
||||
unregisterHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
unregisterHelpCommand.setMaximumArguments(false);
|
||||
|
||||
// Register the base changepassword command
|
||||
CommandDescription changePasswordBaseCommand = new CommandDescription(
|
||||
new ChangePasswordCommand(),
|
||||
@ -448,6 +477,7 @@ public class CommandManager {
|
||||
this.commandDescriptions.add(loginBaseCommand);
|
||||
this.commandDescriptions.add(logoutBaseCommand);
|
||||
this.commandDescriptions.add(registerBaseCommand);
|
||||
this.commandDescriptions.add(unregisterBaseCommand);
|
||||
this.commandDescriptions.add(changePasswordBaseCommand);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
package fr.xephi.authme.command.executable.unregister;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UnregisterCommand 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();
|
||||
|
||||
// Messages instance
|
||||
final Messages m = Messages.getInstance();
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if(!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the password
|
||||
String playerPass = commandArguments.get(0);
|
||||
|
||||
// Get the player instance and name
|
||||
final Player player = (Player) sender;
|
||||
final String playerNameLowerCase = player.getName().toLowerCase();
|
||||
|
||||
// Make sure the player is authenticated
|
||||
if (!PlayerCache.getInstance().isAuthenticated(playerNameLowerCase)) {
|
||||
m.send(player, "not_logged_in");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Unregister the player
|
||||
plugin.management.performUnregister(player, playerPass, false);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user