Implemented the unregister command

This commit is contained in:
Tim Visée
2015-11-01 21:06:19 +01:00
parent ebefca73b7
commit 7f63056cc9
3 changed files with 83 additions and 1 deletions
@@ -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;
}
}