package com.sakurarealm.playerrisk;

import com.sakurarealm.playerrisk.api.PlayerRiskManager;
import com.sakurarealm.playerrisk.api.PlayerRiskSettings;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

public final class PlayerRisk extends JavaPlugin {

    PlayerRiskManager playerRiskManager = null;

    public PlayerRiskManager getPlayerRiskManager() {
        if (playerRiskManager == null) {
            throw new NullPointerException("PlayerRisk plugin is not initialized.");
        }
        return playerRiskManager;
    }

    public void load() {
        saveDefaultConfig();
        FileConfiguration config = getConfig();
        ConfigurationSection settingsSection = config.getConfigurationSection("settings");
        playerRiskManager = new PlayerRiskManager(this, new PlayerRiskSettings(settingsSection));
    }

    @Override
    public void onEnable() {
        // Plugin startup logic
        load();
        getCommand("playerrisk").setExecutor(new CommandHandler(this));
    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

}
