refactor enchant creation

This commit is contained in:
2024-11-03 15:11:30 +01:00
parent 3e5047acb7
commit 55e77cbdf8
11 changed files with 429 additions and 362 deletions
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@SuppressWarnings("UnstableApiUsage")
@@ -28,7 +31,7 @@ public class AirbagEnchant implements EnchantioEnchant {
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
private final double damageReductionPerLevel;
public AirbagEnchant(
private AirbagEnchant(
int anvilCost,
int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
@@ -106,4 +109,42 @@ public class AirbagEnchant implements EnchantioEnchant {
return damageReductionPerLevel;
}
public static AirbagEnchant create(ConfigurationSection configurationSection) {
AirbagEnchant airbagEnchant = new AirbagEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 10),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 40),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"minecraft:elytra"
)
)),
EnchantioConfig.getEquipmentSlotGroups(EnchantioConfig.getStringList(
configurationSection,
"activeSlots",
List.of(
"CHEST"
)
)),
EnchantioConfig.getInt(configurationSection, "maxLevel", 4),
EnchantioConfig.getDouble(configurationSection, "damageReductionPerLevel", 0.2)
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
EnchantioConfig.ENCHANTS.put(airbagEnchant.getKey(), airbagEnchant);
}
return airbagEnchant;
}
}
@@ -5,8 +5,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -14,8 +16,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class BeheadingEnchant implements EnchantioEnchant {
@@ -112,4 +117,42 @@ public class BeheadingEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static BeheadingEnchant create(ConfigurationSection configurationSection) {
BeheadingEnchant beheadingEnchant = new BeheadingEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 1),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 40),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
configurationSection.getBoolean("canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:axes"
)
)),
EnchantioConfig.getEquipmentSlotGroups(EnchantioConfig.getStringList(
configurationSection,
"activeSlots",
List.of(
"MAINHAND"
)
)),
EnchantioConfig.getInt(configurationSection, "maxLevel", 1),
EnchantioConfig.getDouble(configurationSection, "chanceToDropHeadPerLevel", 0.1)
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(BeheadingEnchant.KEY, beheadingEnchant);
}
return beheadingEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class ExecutionerEnchant implements EnchantioEnchant {
@@ -113,4 +118,43 @@ public class ExecutionerEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static ExecutionerEnchant create(ConfigurationSection configurationSection) {
ExecutionerEnchant executionerEnchant = new ExecutionerEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 10),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 40),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:enchantable/weapon"
)
)),
EnchantioConfig.getEquipmentSlotGroups(EnchantioConfig.getStringList(
configurationSection,
"activeSlots",
List.of(
"MAINHAND"
)
)),
EnchantioConfig.getInt(configurationSection, "maxLevel", 5),
EnchantioConfig.getDouble(configurationSection, "damageMultiplierPerLevel", 0.05),
EnchantioConfig.getDouble(configurationSection, "maxDamageHpThreshold", 0.25)
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(ExecutionerEnchant.KEY, executionerEnchant);
}
return executionerEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class HomecomingEnchant implements EnchantioEnchant {
@@ -94,4 +99,33 @@ public class HomecomingEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static HomecomingEnchant create(ConfigurationSection configurationSection) {
HomecomingEnchant homecomingEnchant = new HomecomingEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 10),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 40),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"minecraft:totem_of_undying"
)
))
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(HomecomingEnchant.KEY, homecomingEnchant);
}
return homecomingEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class PanicEnchant implements EnchantioEnchant {
@@ -107,4 +112,42 @@ public class PanicEnchant implements EnchantioEnchant {
return panicChancePerLevel;
}
public static PanicEnchant create(ConfigurationSection configurationSection) {
PanicEnchant panicEnchant = new PanicEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 2),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 0),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 20),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:enchantable/armor"
)
)),
EnchantioConfig.getEquipmentSlotGroups(EnchantioConfig.getStringList(
configurationSection,
"activeSlots",
List.of(
"ARMOR"
)
)),
EnchantioConfig.getInt(configurationSection, "maxLevel", 1),
EnchantioConfig.getDouble(configurationSection, "panicChancePerLevel", 0.025)
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(PanicEnchant.KEY, panicEnchant);
}
return panicEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class ReplantingEnchant implements EnchantioEnchant {
@@ -94,4 +99,33 @@ public class ReplantingEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static ReplantingEnchant create(ConfigurationSection configurationSection) {
ReplantingEnchant replantingEnchant = new ReplantingEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 10),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 1),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 1)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:hoes"
)
))
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(ReplantingEnchant.KEY, replantingEnchant);
}
return replantingEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class SmeltingEnchant implements EnchantioEnchant {
@@ -94,4 +99,33 @@ public class SmeltingEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static SmeltingEnchant create(ConfigurationSection configurationSection) {
SmeltingEnchant smeltingEnchant = new SmeltingEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 10),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 40),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:enchantable/mining"
)
))
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(SmeltingEnchant.KEY, smeltingEnchant);
}
return smeltingEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class SoulboundEnchant implements EnchantioEnchant {
@@ -94,4 +99,35 @@ public class SoulboundEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static SoulboundEnchant create(ConfigurationSection configurationSection) {
SoulboundEnchant soulboundEnchant = new SoulboundEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 10),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 10),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 1)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:enchantable/armor",
"#minecraft:enchantable/weapon",
"#minecraft:enchantable/mining"
)
))
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(SoulboundEnchant.KEY, soulboundEnchant);
}
return soulboundEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class TelepathyEnchant implements EnchantioEnchant {
@@ -54,7 +59,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
@Override
public @NotNull Component getDescription() {
return Component.translatable("enchantio.enchant.telepathy","Telepathy");
return Component.translatable("enchantio.enchant.telepathy", "Telepathy");
}
@Override
@@ -97,4 +102,40 @@ public class TelepathyEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static TelepathyEnchant create(ConfigurationSection configurationSection) {
TelepathyEnchant telepathyEnchant = new TelepathyEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 5),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 15),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 1)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:enchantable/mining"
)
)),
EnchantioConfig.getEquipmentSlotGroups(EnchantioConfig.getStringList(
configurationSection,
"activeSlots",
List.of(
"MAINHAND"
)
))
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(TelepathyEnchant.KEY, telepathyEnchant);
}
return telepathyEnchant;
}
}
@@ -4,8 +4,10 @@ import io.papermc.paper.registry.data.EnchantmentRegistryEntry;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType;
@@ -13,8 +15,11 @@ import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@SuppressWarnings("UnstableApiUsage")
public class VampirismEnchant implements EnchantioEnchant {
@@ -98,4 +103,40 @@ public class VampirismEnchant implements EnchantioEnchant {
return Collections.unmodifiableSet(enchantTagKeys);
}
public static VampirismEnchant create(ConfigurationSection configurationSection) {
VampirismEnchant vampirismEnchant = new VampirismEnchant(
EnchantioConfig.getInt(configurationSection, "anvilCost", 1),
EnchantioConfig.getInt(configurationSection, "weight", 2),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "minimumCost.base", 0),
EnchantioConfig.getInt(configurationSection, "minimumCost.additionalPerLevel", 3)
),
EnchantmentRegistryEntry.EnchantmentCost.of(
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
configurationSection,
"supportedItemTags",
List.of(
"#minecraft:enchantable/armor"
)
)),
EnchantioConfig.getEquipmentSlotGroups(EnchantioConfig.getStringList(
configurationSection,
"activeSlots",
List.of(
"ANY"
)
))
);
if (EnchantioConfig.getBoolean(configurationSection, "enabled", true)) {
ENCHANTS.put(VampirismEnchant.KEY, vampirismEnchant);
}
return vampirismEnchant;
}
}