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.ResidenceManager;

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

public class CommandListAll extends BaseCommand {
    ResidenceMain plugin;

    public CommandListAll(final ResidenceMain plugin) {
        super("la");
        this.plugin = plugin;
        setOnlyPlayerExecutable();
    }

    @Override
    public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
        final Player player = (Player) sender;
        final ResidenceManager rmanager = plugin.getResidenceManager();
        int page = 1;
        try {
            if (args.length > 0) {
                page = Integer.parseInt(args[args.length - 1]);
            }
        } catch (final Exception ex) {
        }
        rmanager.listAllResidences(player, page);
    }

}
