package me.nvus.nvus_prison_setup;

import me.nvus.nvus_prison_setup.Configs.BannedItemsConfig;
import me.nvus.nvus_prison_setup.Listeners.PlayerArmor;
import me.nvus.nvus_prison_setup.Listeners.PlayerItems;
import me.nvus.nvus_prison_setup.Listeners.PlayerSpawn;
import org.bukkit.ChatColor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

public final class PrisonSetup extends JavaPlugin {

    private BannedItemsConfig bannedItemsConfig;

    @Override
    public void onEnable() {

        // Init the BannedItemsConfig
        bannedItemsConfig = new BannedItemsConfig(this);

        // Save banned_items.yml config if it doesn't exist
        bannedItemsConfig.saveDefaultConfig();

        getServer().getPluginManager().registerEvents(new PlayerSpawn(), this);
        getServer().getPluginManager().registerEvents(new PlayerArmor(), this);
        getServer().getPluginManager().registerEvents(new PlayerItems(this), this);
        getLogger().info(ChatColor.translateAlternateColorCodes('&',"&a&lNVus Prison Setup has been successfully enabled!"));

    }

    @Override
    public void onDisable() {
        // Saving config file, just in case it was changed prior to disabling plugin/shutdown?
        bannedItemsConfig.saveConfig();
        getLogger().info(ChatColor.translateAlternateColorCodes('&',"&c&lNVus Prison Setup has been successfully disabled!"));
    }

    public BannedItemsConfig getBannedItemsConfig() {
        return bannedItemsConfig;
    }
}
