package com.yuyu.srdisassemble;

import com.sakurarealm.sritem.bukkit.command.CommandBase;
import com.yuyu.srdisassemble.command.DisCommand;
import com.yuyu.srdisassemble.config.ConfigManager;
import com.yuyu.srdisassemble.data.JdbcSqlClass;
import com.yuyu.srdisassemble.disassemeble.TemporarilyBox;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.logging.Level;

public final class SrDisassemble extends JavaPlugin {


    @Getter
    private static ConfigManager configManager;//用于鉴定


    @Override
    public void onEnable() {
        // Plugin startup logic
        getLogger().info(ChatColor.GOLD+"分解插件开始运行!");
        this.configManager = new ConfigManager(this);

        //注册指令
        CommandBase commandBase = new CommandBase();
        this.getCommand("srdisassemble").setExecutor(commandBase);
        commandBase.registerSubCommand("open",new DisCommand());
        commandBase.registerSubCommand("reload",new DisCommand());

        Bukkit.getServer().getPluginManager().registerEvents(new TemporarilyBox(),this);

        //读取暂存箱
        JdbcSqlClass.createPauseBoxTable();
//        JdbcSqlClass.setPauseBox2UTF();
        TemporarilyBox.getPauseBoxData();



    }

    @Override
    public void onDisable() {
        JdbcSqlClass.clearPauseBoxTable("TemporarilyBox-disassemble");
        // Plugin shutdown logic
        TemporarilyBox.savePauseBoxData();
    }
}
