refactor to allow adding enchantment tags freely

This commit is contained in:
2025-05-16 19:22:10 +02:00
parent 6c64ab87c2
commit ef16d1cb28
15 changed files with 218 additions and 210 deletions
@@ -2,6 +2,7 @@ package me.youhavetrouble.enchantio;
import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.TypedKey; import io.papermc.paper.registry.TypedKey;
import io.papermc.paper.registry.keys.tags.EnchantmentTagKeys;
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys; import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
import io.papermc.paper.registry.tag.TagKey; import io.papermc.paper.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
@@ -10,6 +11,7 @@ import net.kyori.adventure.key.Key;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.EquipmentSlotGroup; import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -41,6 +43,7 @@ public class EnchantioConfig {
FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile); FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
ConfigurationSection enchantsSection = getConfigSection(configuration, "enchants"); ConfigurationSection enchantsSection = getConfigSection(configuration, "enchants");
migrateEnchantTags(enchantsSection);
ConfigurationSection soulboundSection = getConfigSection(enchantsSection, "soulbound"); ConfigurationSection soulboundSection = getConfigSection(enchantsSection, "soulbound");
SoulboundEnchant.create(soulboundSection); SoulboundEnchant.create(soulboundSection);
@@ -76,6 +79,7 @@ public class EnchantioConfig {
WardEnchant.create(wardSection); WardEnchant.create(wardSection);
ConfigurationSection cursesSection = getConfigSection(configuration, "curses"); ConfigurationSection cursesSection = getConfigSection(configuration, "curses");
migrateEnchantTags(cursesSection);
ConfigurationSection panicSection = getConfigSection(cursesSection, "panic"); ConfigurationSection panicSection = getConfigSection(cursesSection, "panic");
PanicEnchant.create(panicSection); PanicEnchant.create(panicSection);
@@ -134,6 +138,16 @@ public class EnchantioConfig {
return true; return true;
} }
public static void migrateEnchantTags(@NotNull ConfigurationSection section) {
for (String sectionKey : section.getKeys(false)) {
ConfigurationSection enchantSection = section.getConfigurationSection(sectionKey);
if (enchantSection == null) continue;
if (!enchantSection.isSet("canGetFromEnchantingTable") || enchantSection.isSet("enchantmentTags")) return;
boolean canGetFromEnchantingTable = section.getBoolean("canGetFromEnchantingTable", true);
section.set("enchantmentTags", canGetFromEnchantingTable ? List.of("#in_enchanting_table") : List.of());
}
}
public static Set<EquipmentSlotGroup> getEquipmentSlotGroups(@NotNull List<String> slots) { public static Set<EquipmentSlotGroup> getEquipmentSlotGroups(@NotNull List<String> slots) {
Set<EquipmentSlotGroup> equipmentSlotGroups = new HashSet<>(); Set<EquipmentSlotGroup> equipmentSlotGroups = new HashSet<>();
for (String slot : slots) { for (String slot : slots) {
@@ -146,7 +160,7 @@ public class EnchantioConfig {
return equipmentSlotGroups; return equipmentSlotGroups;
} }
public static Set<TagEntry<ItemType>> getTagsFromList(@NotNull List<String> tags) { public static Set<TagEntry<ItemType>> getItemTagEntriesFromList(@NotNull List<String> tags) {
Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>(); Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
for (String itemTag : tags) { for (String itemTag : tags) {
if (itemTag == null) continue; if (itemTag == null) continue;
@@ -172,6 +186,31 @@ public class EnchantioConfig {
return supportedItemTags; return supportedItemTags;
} }
public static Set<TagKey<Enchantment>> getEnchantmentTagKeysFromList(@NotNull List<String> tags) {
Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
for (String enchantmentTag : tags) {
if (enchantmentTag == null) continue;
if (enchantmentTag.startsWith("#")) {
enchantmentTag = enchantmentTag.substring(1);
try {
Key key = Key.key(enchantmentTag);
TagKey<Enchantment> tagKey = EnchantmentTagKeys.create(key);
enchantTagKeys.add(tagKey);
} catch (IllegalArgumentException ignored) {
}
continue;
}
try {
Key key = Key.key(enchantmentTag);
TypedKey<Enchantment> typedKey = TypedKey.create(RegistryKey.ENCHANTMENT, key);
TagKey<Enchantment> tagKey = EnchantmentTagKeys.create(key);
enchantTagKeys.add(tagKey);
} catch (IllegalArgumentException | NullPointerException ignored) {
}
}
return enchantTagKeys;
}
public static ConfigurationSection getConfigSection(ConfigurationSection section, String key) { public static ConfigurationSection getConfigSection(ConfigurationSection section, String key) {
ConfigurationSection value = section.getConfigurationSection(key); ConfigurationSection value = section.getConfigurationSection(key);
if (value == null) { if (value == null) {
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@SuppressWarnings("UnstableApiUsage") @SuppressWarnings("UnstableApiUsage")
public class AirbagEnchant implements EnchantioEnchant { public class AirbagEnchant implements EnchantioEnchant {
@@ -26,7 +22,7 @@ public class AirbagEnchant implements EnchantioEnchant {
private final int anvilCost, weight, maxLevel; private final int anvilCost, weight, maxLevel;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
private final double damageReductionPerLevel; private final double damageReductionPerLevel;
@@ -36,9 +32,9 @@ public class AirbagEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int maxLevel, int maxLevel,
double damageReductionPerLevel double damageReductionPerLevel
) { ) {
@@ -47,12 +43,10 @@ public class AirbagEnchant implements EnchantioEnchant {
this.maxLevel = maxLevel; this.maxLevel = maxLevel;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.damageReductionPerLevel = damageReductionPerLevel; this.damageReductionPerLevel = damageReductionPerLevel;
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -121,8 +115,12 @@ public class AirbagEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -2,7 +2,6 @@ package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -14,10 +13,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -29,7 +25,7 @@ public class BeheadingEnchant implements EnchantioEnchant {
private final int anvilCost, weight, maxLevel; private final int anvilCost, weight, maxLevel;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
private final Set<TagEntry<ItemType>> supportedItemTags; private final Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
private final double chanceToDropHeadPerLevel; private final double chanceToDropHeadPerLevel;
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>(); private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -39,9 +35,9 @@ public class BeheadingEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int maxLevel, int maxLevel,
double chanceToDropHeadPerLevel double chanceToDropHeadPerLevel
) { ) {
@@ -49,13 +45,11 @@ public class BeheadingEnchant implements EnchantioEnchant {
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.maxLevel = maxLevel; this.maxLevel = maxLevel;
this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel; this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel;
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -129,8 +123,12 @@ public class BeheadingEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
configurationSection.getBoolean("canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class CloakingEnchant implements EnchantioEnchant {
private final int anvilCost, weight, ticksToActivate; private final int anvilCost, weight, ticksToActivate;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -37,21 +33,19 @@ public class CloakingEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int ticksToActivate int ticksToActivate
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.ticksToActivate = ticksToActivate; this.ticksToActivate = ticksToActivate;
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -120,8 +114,12 @@ public class CloakingEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class ExecutionerEnchant implements EnchantioEnchant {
private final int anvilCost, weight, maxLevel; private final int anvilCost, weight, maxLevel;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
private final Set<TagEntry<ItemType>> supportedItemTags; private final Set<TagEntry<ItemType>> supportedItemTags = new HashSet<>();
private final double damageMultiplierPerLevel, maxDamageHpThreshold; private final double damageMultiplierPerLevel, maxDamageHpThreshold;
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>(); private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -39,9 +35,9 @@ public class ExecutionerEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int maxLevel, int maxLevel,
double damageMultiplierPerLevel, double damageMultiplierPerLevel,
double maxDamageHpThreshold double maxDamageHpThreshold
@@ -50,14 +46,12 @@ public class ExecutionerEnchant implements EnchantioEnchant {
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.maxLevel = maxLevel; this.maxLevel = maxLevel;
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
this.damageMultiplierPerLevel = damageMultiplierPerLevel; this.damageMultiplierPerLevel = damageMultiplierPerLevel;
this.maxDamageHpThreshold = maxDamageHpThreshold; this.maxDamageHpThreshold = maxDamageHpThreshold;
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -130,8 +124,12 @@ public class ExecutionerEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class HomecomingEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
public HomecomingEnchant( public HomecomingEnchant(
@@ -36,17 +32,15 @@ public class HomecomingEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags Collection<TagEntry<ItemType>> supportedItemTags
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -111,8 +105,12 @@ public class HomecomingEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class InsomniaEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -37,20 +33,17 @@ public class InsomniaEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots Collection<EquipmentSlotGroup> activeSlots
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
enchantTagKeys.add(EnchantmentTagKeys.CURSE);
} }
@Override @Override
@@ -115,8 +108,12 @@ public class InsomniaEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table", "#curse")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; 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 minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
private final double panicChancePerLevel; 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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -38,9 +34,9 @@ public class PanicEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int maxLevel, int maxLevel,
double panicChancePerLevel double panicChancePerLevel
) { ) {
@@ -49,13 +45,10 @@ public class PanicEnchant implements EnchantioEnchant {
this.maxLevel = maxLevel; this.maxLevel = maxLevel;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.panicChancePerLevel = panicChancePerLevel; this.panicChancePerLevel = panicChancePerLevel;
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
enchantTagKeys.add(EnchantmentTagKeys.CURSE);
} }
@Override @Override
@@ -124,8 +117,12 @@ public class PanicEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 20), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 20),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table", "#curse")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class ReplantingEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
public ReplantingEnchant( public ReplantingEnchant(
@@ -36,17 +32,15 @@ public class ReplantingEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags Collection<TagEntry<ItemType>> supportedItemTags
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -111,8 +105,12 @@ public class ReplantingEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class SmeltingEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
public SmeltingEnchant( public SmeltingEnchant(
@@ -36,17 +32,15 @@ public class SmeltingEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags Collection<TagEntry<ItemType>> supportedItemTags
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -111,8 +105,12 @@ public class SmeltingEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class SoulboundEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
public SoulboundEnchant( public SoulboundEnchant(
@@ -36,17 +32,15 @@ public class SoulboundEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags Collection<TagEntry<ItemType>> supportedItemTags
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -111,8 +105,12 @@ public class SoulboundEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -37,19 +33,17 @@ public class TelepathyEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots Collection<EquipmentSlotGroup> activeSlots
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -114,8 +108,12 @@ public class TelepathyEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class VampirismEnchant implements EnchantioEnchant {
private final int anvilCost, weight; private final int anvilCost, weight;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
@@ -37,20 +33,17 @@ public class VampirismEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots Collection<EquipmentSlotGroup> activeSlots
) { ) {
this.anvilCost = anvilCost; this.anvilCost = anvilCost;
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
enchantTagKeys.add(EnchantmentTagKeys.CURSE);
} }
@Override @Override
@@ -115,8 +108,12 @@ public class VampirismEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table", "#curse")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class VolleyEnchant implements EnchantioEnchant {
private final int anvilCost, weight, maxLevel, additionalArrowsPerLevel; private final int anvilCost, weight, maxLevel, additionalArrowsPerLevel;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
private final double spread; private final double spread;
@@ -38,9 +34,9 @@ public class VolleyEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int maxLevel, int maxLevel,
int additionalArrowsPerLevel, int additionalArrowsPerLevel,
double spread double spread
@@ -49,14 +45,12 @@ public class VolleyEnchant implements EnchantioEnchant {
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.maxLevel = maxLevel; this.maxLevel = maxLevel;
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
this.additionalArrowsPerLevel = additionalArrowsPerLevel; this.additionalArrowsPerLevel = additionalArrowsPerLevel;
this.spread = spread; this.spread = spread;
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -129,8 +123,12 @@ public class VolleyEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(
@@ -1,7 +1,6 @@
package me.youhavetrouble.enchantio.enchants; package me.youhavetrouble.enchantio.enchants;
import io.papermc.paper.registry.data.EnchantmentRegistryEntry; 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.registry.tag.TagKey;
import io.papermc.paper.tag.TagEntry; import io.papermc.paper.tag.TagEntry;
import me.youhavetrouble.enchantio.EnchantioConfig; import me.youhavetrouble.enchantio.EnchantioConfig;
@@ -13,10 +12,7 @@ import org.bukkit.inventory.EquipmentSlotGroup;
import org.bukkit.inventory.ItemType; import org.bukkit.inventory.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collections; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS; import static me.youhavetrouble.enchantio.EnchantioConfig.ENCHANTS;
@@ -28,7 +24,7 @@ public class WardEnchant implements EnchantioEnchant {
private final int anvilCost, weight, cooldownTicks; private final int anvilCost, weight, cooldownTicks;
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost; private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost; private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
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<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>(); private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
private final String blockSound; private final String blockSound;
@@ -38,9 +34,9 @@ public class WardEnchant implements EnchantioEnchant {
int weight, int weight,
EnchantmentRegistryEntry.EnchantmentCost minimumCost, EnchantmentRegistryEntry.EnchantmentCost minimumCost,
EnchantmentRegistryEntry.EnchantmentCost maximumCost, EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable, Collection<TagKey<Enchantment>> enchantTagKeys,
Set<TagEntry<ItemType>> supportedItemTags, Collection<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots, Collection<EquipmentSlotGroup> activeSlots,
int cooldownTicks, int cooldownTicks,
String blockSound String blockSound
) { ) {
@@ -48,13 +44,11 @@ public class WardEnchant implements EnchantioEnchant {
this.weight = weight; this.weight = weight;
this.minimumCost = minimumCost; this.minimumCost = minimumCost;
this.maximumCost = maximumCost; this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags; this.supportedItemTags.addAll(supportedItemTags);
this.activeSlots.addAll(activeSlots); this.activeSlots.addAll(activeSlots);
this.cooldownTicks = cooldownTicks; this.cooldownTicks = cooldownTicks;
this.blockSound = blockSound; this.blockSound = blockSound;
if (canGetFromEnchantingTable) { this.enchantTagKeys.addAll(enchantTagKeys);
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
} }
@Override @Override
@@ -127,8 +121,12 @@ public class WardEnchant implements EnchantioEnchant {
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65), EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1) EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
), ),
EnchantioConfig.getBoolean(configurationSection, "canGetFromEnchantingTable", true), EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList( configurationSection,
"enchantmentTags",
List.of("#in_enchanting_table")
)),
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
configurationSection, configurationSection,
"supportedItemTags", "supportedItemTags",
List.of( List.of(