mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-14 16:08:56 +02:00
Implemented the logout command
This commit is contained in:
parent
ebd25e16a0
commit
ebefca73b7
@ -350,7 +350,7 @@ public class AuthMe extends JavaPlugin {
|
||||
//getCommand("register").setExecutor(new RegisterCommand(this));
|
||||
//getCommand("login").setExecutor(new LoginCommand(this));
|
||||
//getCommand("changepassword").setExecutor(new ChangePasswordCommand(this));
|
||||
getCommand("logout").setExecutor(new LogoutCommand(this));
|
||||
//getCommand("logout").setExecutor(new LogoutCommand(this));
|
||||
getCommand("unregister").setExecutor(new UnregisterCommand(this));
|
||||
getCommand("email").setExecutor(new EmailCommand(this));
|
||||
getCommand("captcha").setExecutor(new CaptchaCommand(this));
|
||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.command.executable.*;
|
||||
import fr.xephi.authme.command.executable.authme.*;
|
||||
import fr.xephi.authme.command.executable.changepassword.ChangePasswordCommand;
|
||||
import fr.xephi.authme.command.executable.login.LoginCommand;
|
||||
import fr.xephi.authme.command.executable.logout.LogoutCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -356,6 +357,32 @@ public class CommandManager {
|
||||
loginHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
loginHelpCommand.setMaximumArguments(false);
|
||||
|
||||
// Register the base logout command
|
||||
CommandDescription logoutBaseCommand = new CommandDescription(
|
||||
new LogoutCommand(),
|
||||
new ArrayList<String>() {{
|
||||
add("logout");
|
||||
}},
|
||||
"Logout command",
|
||||
"Command to logout using AuthMeReloaded.", null);
|
||||
logoutBaseCommand.setCommandPermissions("authme.logout", CommandPermissions.DefaultPermission.ALLOWED);
|
||||
|
||||
// Register the help command
|
||||
CommandDescription logoutHelpCommand = 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.",
|
||||
logoutBaseCommand);
|
||||
logoutHelpCommand.addArgument(new CommandArgumentDescription("query", "The command or query to view help for.", true));
|
||||
logoutHelpCommand.setMaximumArguments(false);
|
||||
|
||||
// Register the base register command
|
||||
CommandDescription registerBaseCommand = new CommandDescription(
|
||||
new RegisterCommand(),
|
||||
@ -419,6 +446,7 @@ public class CommandManager {
|
||||
// Add the base commands to the commands array
|
||||
this.commandDescriptions.add(authMeBaseCommand);
|
||||
this.commandDescriptions.add(loginBaseCommand);
|
||||
this.commandDescriptions.add(logoutBaseCommand);
|
||||
this.commandDescriptions.add(registerBaseCommand);
|
||||
this.commandDescriptions.add(changePasswordBaseCommand);
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package fr.xephi.authme.command.executable.logout;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LogoutCommand 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();
|
||||
|
||||
// Make sure the current command executor is a player
|
||||
if(!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the player instance
|
||||
final Player player = (Player) sender;
|
||||
|
||||
// Logout the player
|
||||
plugin.management.performLogout(player);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user