package pw.yumc.Residence.commandmain;

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

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

public class CommandResReload extends BaseCommand {
    ResidenceMain plugin;

    public CommandResReload(final ResidenceMain plugin) {
        super("resreload");
        this.plugin = plugin;
    }

    @Override
    public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
        if (sender instanceof Player) {
            final Player player = (Player) sender;
            if (plugin.getPermissionManager().isResidenceAdmin(player)) {
                plugin.reloadPlugin();
                sender.sendMessage(ChatColor.GREEN + "[Residence] 重载配置文件.");
                plugin.getLogger().info("重载 by " + player.getName() + ".");
            }
        } else {
            plugin.reloadPlugin();
            plugin.getLogger().info("重载 by 控制台.");
        }
    }

}
