package cn.citycraft.AuthMe.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import cn.citycraft.AuthMe.AuthMe;
import cn.citycraft.AuthMe.settings.Messages;

public class LogoutCommand implements CommandExecutor {

	private Messages m = Messages.getInstance();
	private AuthMe plugin;

	public LogoutCommand(AuthMe plugin) {
		this.plugin = plugin;
	}

	@Override
	public boolean onCommand(CommandSender sender, Command cmnd, String label, String[] args) {
		if (!(sender instanceof Player)) {
			return true;
		}

		if (!plugin.authmePermissible(sender, "authme." + label.toLowerCase())) {
			m.send(sender, "no_perm");
			return true;
		}

		final Player player = (Player) sender;
		plugin.management.performLogout(player);
		return true;
	}

}
