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 InfinityEnchantment extends Enchantment {
    private final String id;

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

    private static final List<String> enchantmentIds = 
        Arrays.asList("minecraft:infinity","minecraft:mending");

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

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

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