package com.yaohun.demonskills.config;

import com.yaohun.demonskills.SkillsMain;
import me.Demon.DemonPlugin.DemonAPI;
import me.Demon.DemonPlugin.data.LangData;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Config {
    public static LangData langData;
    private static List<String> disableWorlds = new ArrayList<>();

    public static void reloadConfig(SkillsMain plugin) {
        langData = DemonAPI.getLangData("DemonSkills");
        File file = new File(plugin.getDataFolder(), "settings.yml");
        if (!file.exists()) {
            file.getParentFile().mkdirs();
            try {
                file.createNewFile();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        FileConfiguration config = YamlConfiguration.loadConfiguration(file);
        disableWorlds = config.getStringList("Disable-Worlds");
        Bukkit.getConsoleSender().sendMessage("§d[技能系统] §7禁用世界: §7"+String.join("§f, §7", disableWorlds));
    }

    public static boolean isDisableWorld(String world) {
        return disableWorlds.contains(world);
    }

}
