package com.mingliqiye.minecraft.enchantment.conflict.enchantment;

import com.mingliqiye.minecraft.enchantment.conflict.config.ModConfig;

import java.util.Arrays;
import java.util.List;

public class ProtectionEnchantment extends Enchantment {
    private final String id;

    private ProtectionEnchantment(String id) {
        this.id = id;
    }

    private static final List<String> enchantmentIds = 
        Arrays.asList(
            "minecraft:protection",
            "minecraft:fire_protection",
            "minecraft:blast_protection",
            "minecraft:projectile_protection"
        );

    public static ProtectionEnchantment ofId(String id) {
        if (enchantmentIds.contains(id)) {
            return new ProtectionEnchantment(id);
        }
        return null;
    }

    @Override
    public Boolean canBeCombined(Enchantment enchantment) {
        if (enchantment instanceof ProtectionEnchantment) {
            return ModConfig.getInstance().isAllowProtectionEnchantment();
        }
        return super.canBeCombined(enchantment);
    }

    @Override
    public String getId() {
        return id;
    }
}
