mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-11 21:56:55 +00:00
refactor to allow adding enchantment tags freely
This commit is contained in:
@@ -2,6 +2,7 @@ package me.youhavetrouble.enchantio;
|
||||
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
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.tag.TagKey;
|
||||
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.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,6 +43,7 @@ public class EnchantioConfig {
|
||||
FileConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
ConfigurationSection enchantsSection = getConfigSection(configuration, "enchants");
|
||||
migrateEnchantTags(enchantsSection);
|
||||
|
||||
ConfigurationSection soulboundSection = getConfigSection(enchantsSection, "soulbound");
|
||||
SoulboundEnchant.create(soulboundSection);
|
||||
@@ -76,6 +79,7 @@ public class EnchantioConfig {
|
||||
WardEnchant.create(wardSection);
|
||||
|
||||
ConfigurationSection cursesSection = getConfigSection(configuration, "curses");
|
||||
migrateEnchantTags(cursesSection);
|
||||
|
||||
ConfigurationSection panicSection = getConfigSection(cursesSection, "panic");
|
||||
PanicEnchant.create(panicSection);
|
||||
@@ -134,6 +138,16 @@ public class EnchantioConfig {
|
||||
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) {
|
||||
Set<EquipmentSlotGroup> equipmentSlotGroups = new HashSet<>();
|
||||
for (String slot : slots) {
|
||||
@@ -146,7 +160,7 @@ public class EnchantioConfig {
|
||||
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<>();
|
||||
for (String itemTag : tags) {
|
||||
if (itemTag == null) continue;
|
||||
@@ -172,6 +186,31 @@ public class EnchantioConfig {
|
||||
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) {
|
||||
ConfigurationSection value = section.getConfigurationSection(key);
|
||||
if (value == null) {
|
||||
|
||||
@@ -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.*;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class AirbagEnchant implements EnchantioEnchant {
|
||||
@@ -26,7 +22,7 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight, maxLevel;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
private final double damageReductionPerLevel;
|
||||
@@ -36,9 +32,9 @@ public class AirbagEnchant 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 damageReductionPerLevel
|
||||
) {
|
||||
@@ -47,12 +43,10 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
this.maxLevel = maxLevel;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.damageReductionPerLevel = damageReductionPerLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,8 +115,12 @@ public class AirbagEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -2,7 +2,6 @@ package me.youhavetrouble.enchantio.enchants;
|
||||
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
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;
|
||||
@@ -14,10 +13,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 BeheadingEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight, maxLevel;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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 Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
@@ -39,9 +35,9 @@ public class BeheadingEnchant 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 chanceToDropHeadPerLevel
|
||||
) {
|
||||
@@ -49,13 +45,11 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.maxLevel = maxLevel;
|
||||
this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,8 +123,12 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.additionalPerLevel", 1)
|
||||
),
|
||||
configurationSection.getBoolean("canGetFromEnchantingTable", true),
|
||||
EnchantioConfig.getTagsFromList(EnchantioConfig.getStringList(
|
||||
EnchantioConfig.getEnchantmentTagKeysFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"enchantmentTags",
|
||||
List.of("#in_enchanting_table")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class CloakingEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight, ticksToActivate;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
@@ -37,21 +33,19 @@ public class CloakingEnchant 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 ticksToActivate
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.ticksToActivate = ticksToActivate;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,8 +114,12 @@ public class CloakingEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight, maxLevel;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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 Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
@@ -39,9 +35,9 @@ public class ExecutionerEnchant 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 damageMultiplierPerLevel,
|
||||
double maxDamageHpThreshold
|
||||
@@ -50,14 +46,12 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.maxLevel = maxLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
this.damageMultiplierPerLevel = damageMultiplierPerLevel;
|
||||
this.maxDamageHpThreshold = maxDamageHpThreshold;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -130,8 +124,12 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class HomecomingEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<>();
|
||||
|
||||
public HomecomingEnchant(
|
||||
@@ -36,17 +32,15 @@ public class HomecomingEnchant implements EnchantioEnchant {
|
||||
int weight,
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags
|
||||
Collection<TagKey<Enchantment>> enchantTagKeys,
|
||||
Collection<TagEntry<ItemType>> supportedItemTags
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,8 +105,12 @@ public class HomecomingEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class InsomniaEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
@@ -37,20 +33,17 @@ public class InsomniaEnchant 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
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
enchantTagKeys.add(EnchantmentTagKeys.CURSE);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,8 +108,12 @@ public class InsomniaEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30),
|
||||
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(
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<>();
|
||||
|
||||
public ReplantingEnchant(
|
||||
@@ -36,17 +32,15 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
||||
int weight,
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags
|
||||
Collection<TagKey<Enchantment>> enchantTagKeys,
|
||||
Collection<TagEntry<ItemType>> supportedItemTags
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,8 +105,12 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<>();
|
||||
|
||||
public SmeltingEnchant(
|
||||
@@ -36,17 +32,15 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
||||
int weight,
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags
|
||||
Collection<TagKey<Enchantment>> enchantTagKeys,
|
||||
Collection<TagEntry<ItemType>> supportedItemTags
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,8 +105,12 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<>();
|
||||
|
||||
public SoulboundEnchant(
|
||||
@@ -36,17 +32,15 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
||||
int weight,
|
||||
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
||||
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
||||
boolean canGetFromEnchantingTable,
|
||||
Set<TagEntry<ItemType>> supportedItemTags
|
||||
Collection<TagKey<Enchantment>> enchantTagKeys,
|
||||
Collection<TagEntry<ItemType>> supportedItemTags
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,8 +105,12 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
@@ -37,19 +33,17 @@ public class TelepathyEnchant 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
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -114,8 +108,12 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class VampirismEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
|
||||
@@ -37,20 +33,17 @@ public class VampirismEnchant 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
|
||||
) {
|
||||
this.anvilCost = anvilCost;
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
enchantTagKeys.add(EnchantmentTagKeys.CURSE);
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,8 +108,12 @@ public class VampirismEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 30),
|
||||
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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight, maxLevel, additionalArrowsPerLevel;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
private final double spread;
|
||||
@@ -38,9 +34,9 @@ public class VolleyEnchant 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,
|
||||
int additionalArrowsPerLevel,
|
||||
double spread
|
||||
@@ -49,14 +45,12 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.maxLevel = maxLevel;
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
this.additionalArrowsPerLevel = additionalArrowsPerLevel;
|
||||
this.spread = spread;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,8 +123,12 @@ public class VolleyEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +24,7 @@ public class WardEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight, cooldownTicks;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
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<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
||||
private final String blockSound;
|
||||
@@ -38,9 +34,9 @@ public class WardEnchant 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 cooldownTicks,
|
||||
String blockSound
|
||||
) {
|
||||
@@ -48,13 +44,11 @@ public class WardEnchant implements EnchantioEnchant {
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
this.supportedItemTags.addAll(supportedItemTags);
|
||||
this.activeSlots.addAll(activeSlots);
|
||||
this.cooldownTicks = cooldownTicks;
|
||||
this.blockSound = blockSound;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
this.enchantTagKeys.addAll(enchantTagKeys);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,8 +121,12 @@ public class WardEnchant implements EnchantioEnchant {
|
||||
EnchantioConfig.getInt(configurationSection, "maximumCost.base", 65),
|
||||
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")
|
||||
)),
|
||||
EnchantioConfig.getItemTagEntriesFromList(EnchantioConfig.getStringList(
|
||||
configurationSection,
|
||||
"supportedItemTags",
|
||||
List.of(
|
||||
|
||||
Reference in New Issue
Block a user