package pw.yumc.Residence.commandsub;

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

import com.bekvon.bukkit.residence.protection.FlagPermissions;

import cn.citycraft.PluginHelper.commands.BaseCommand;
import pw.yumc.Residence.ResidenceMain;

public class CommandCheckSelf extends BaseCommand {
    ResidenceMain plugin;

    public CommandCheckSelf(final ResidenceMain plugin) {
        super("cs");
        this.plugin = plugin;
        setOnlyPlayerExecutable();
        setPossibleArguments("[权限]");
    }

    @Override
    public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
        final Player player = (Player) sender;
        final FlagPermissions perm = plugin.getPermsByLocForPlayer(player.getLocation(), player);
        switch (args.length) {
        case 0:
            player.sendMessage("§e权限列表: ");
            perm.printFlags(player);
            return;
        case 1:
            final String flag = args[0];
            player.sendMessage("§e权限检查: §a" + flag + " " + (perm.checkValidFlag(flag, false) ? "§atrue" : "§cfalse"));
            return;
        }
    }

}
