package com.yuyu.srdisassemble.command;

import com.germ.germplugin.api.dynamic.gui.GermGuiScreen;
import com.sakurarealm.sritem.bukkit.command.SubCommand;
import com.yuyu.srdisassemble.SrDisassemble;
import com.yuyu.srdisassemble.disassemeble.DisassembleManager;
import com.yuyu.srdisassemble.disassemeble.SassembleGuiService;
import com.yuyu.srdisassemble.disassemeble.TemporarilyBox;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

/**
 * @author 峰。
 * @version 1.0
 * @project SrDisassemble
 * @date 2024/6/11 16:11:24
 * @description
 */
public class DisCommand implements SubCommand {
    @Override
    public void onCommand(CommandSender commandSender, String[] strings) {
        if (strings.length == 1) {
            if (strings[0].equalsIgnoreCase("reload")){
                commandSender.sendMessage(ChatColor.RED+"分解配置文件重载!");
                //重载文件
                SrDisassemble.getConfigManager().reload();
                return;
            }
        }


        if (strings.length < 2){
            commandSender.sendMessage(ChatColor.RED+"正确的格式为:/disassemble open 姓名 ");
            return;
        }

        Player player = Bukkit.getPlayer(strings[1]);
        if (player == null){
            commandSender.sendMessage(ChatColor.RED+"玩家"+strings[1]+"不存在!");
            return;
        }

            //为玩家打开GUI列表
            DisassembleManager.getInstance().open(player);

    }
}
