mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
refactor to allow adding enchantment tags freely
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package me.youhavetrouble.enchantio.enchants;
|
||||
|
||||
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;
|
||||
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
|
||||
|
||||
@@ -29,7 +25,7 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
||||
private final double panicChancePerLevel;
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
@@ -38,9 +34,9 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
int weight,
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags,
|
||||
Set<EquipmentSlotGroup> activeSlots,
|
||||
Collection<TagKey<Enchantment>> enchantTagKeys,
|
||||
Collection<TagEntry<ItemType>> supportedItemTags,
|
||||
Collection<EquipmentSlotGroup> activeSlots,
|
||||
int maxLevel,
|
||||
double panicChancePerLevel
|
||||
) {
|
||||
@@ -49,13 +45,10 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
this.maxLevel = maxLevel;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.panicChancePerLevel = panicChancePerLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
enchantTagKeys.add(EnchantmentTagKeys.CURSE);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,8 +117,12 @@ public class PanicEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 20),
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
|
||||
),
|
||||
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true),
|
||||
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
|
||||
EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"enchantmentTags",
|
||||
List.of("#in_enchanting_table", "#curse")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
Reference in New Issue
Block a user