package xyz.quickbasic.tieredrepairkits;

import xyz.quickbasic.tieredrepairkits.config.RepairTier;

import java.util.Map;

// Manages repair-kit data for the plugin
public class RepairKitManager {

    private final TieredRepairKits plugin;
    private Map<String, RepairTier> tiers;

    public RepairKitManager(TieredRepairKits plugin) {
        this.plugin = plugin;
        loadConfig();
    }

    public void loadConfig() {
        TRKConfig config = plugin.getConfig().get();
        tiers = config.getTiers();

        // Log loaded tiers
        for (var entry : tiers.entrySet()) {
            String tierName = entry.getKey();
            RepairTier tier = entry.getValue();

            TieredRepairKits.LOGGER.atInfo().log("Loaded tier: " + tierName);
            TieredRepairKits.LOGGER.atInfo().log("Enabled: " + tier.isEnabled());
            TieredRepairKits.LOGGER.atInfo().log("RepairPenalty: " + tier.getRepairPenalty());
            TieredRepairKits.LOGGER.atInfo().log("Recipe size: " + tier.getRecipe().size());
        }
    }

    public Map<String, RepairTier> getTiers() {
        return tiers;
    }

    public RepairTier getTier(String name) {
        return tiers.get(name);
    }
}