mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-11 21:56:55 +00:00
refactor to allow adding enchants to arbitrary tags
This commit is contained in:
@@ -6,16 +6,12 @@ import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
|
|||||||
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.event.RegistryEvents;
|
import io.papermc.paper.registry.event.RegistryEvents;
|
||||||
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.tag.TagEntry;
|
|
||||||
import me.youhavetrouble.enchantio.enchants.EnchantioEnchant;
|
import me.youhavetrouble.enchantio.enchants.EnchantioEnchant;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@@ -26,19 +22,18 @@ public class EnchantioBootstrap implements PluginBootstrap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bootstrap(@NotNull BootstrapContext context) {
|
public void bootstrap(@NotNull BootstrapContext context) {
|
||||||
EnchantioConfig config;
|
|
||||||
try {
|
try {
|
||||||
config = new EnchantioConfig(context.getDataDirectory(), logger);
|
new EnchantioConfig(context.getDataDirectory(), logger);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection<EnchantioEnchant> enchantioEnchants = EnchantioConfig.ENCHANTS.values();
|
Collection<EnchantioEnchant> enchantioEnchants = EnchantioConfig.ENCHANTS.values();
|
||||||
|
|
||||||
logger.info("Registering supported item tags");
|
logger.fine("Registering supported item tags");
|
||||||
context.getLifecycleManager().registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM).newHandler((event) -> {
|
context.getLifecycleManager().registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ITEM).newHandler((event) -> {
|
||||||
for (EnchantioEnchant enchant : enchantioEnchants) {
|
for (EnchantioEnchant enchant : enchantioEnchants) {
|
||||||
logger.info("Registering item tag " + enchant.getTagForSupportedItems().key());
|
logger.fine("Registering item tag " + enchant.getTagForSupportedItems().key());
|
||||||
event.registrar().addToTag(
|
event.registrar().addToTag(
|
||||||
ItemTypeTagKeys.create(enchant.getTagForSupportedItems().key()),
|
ItemTypeTagKeys.create(enchant.getTagForSupportedItems().key()),
|
||||||
enchant.getSupportedItems()
|
enchant.getSupportedItems()
|
||||||
@@ -48,7 +43,7 @@ public class EnchantioBootstrap implements PluginBootstrap {
|
|||||||
|
|
||||||
context.getLifecycleManager().registerEventHandler(RegistryEvents.ENCHANTMENT.freeze().newHandler(event -> {
|
context.getLifecycleManager().registerEventHandler(RegistryEvents.ENCHANTMENT.freeze().newHandler(event -> {
|
||||||
for (EnchantioEnchant enchant : enchantioEnchants) {
|
for (EnchantioEnchant enchant : enchantioEnchants) {
|
||||||
logger.info("Registering enchantment " + enchant.getKey());
|
logger.fine("Registering enchantment " + enchant.getKey());
|
||||||
event.registry().register(TypedKey.create(RegistryKey.ENCHANTMENT, enchant.getKey()), enchantment -> {
|
event.registry().register(TypedKey.create(RegistryKey.ENCHANTMENT, enchant.getKey()), enchantment -> {
|
||||||
enchantment.description(enchant.getDescription());
|
enchantment.description(enchant.getDescription());
|
||||||
enchantment.anvilCost(enchant.getAnvilCost());
|
enchantment.anvilCost(enchant.getAnvilCost());
|
||||||
@@ -63,13 +58,12 @@ public class EnchantioBootstrap implements PluginBootstrap {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
context.getLifecycleManager().registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ENCHANTMENT).newHandler((event) -> {
|
context.getLifecycleManager().registerEventHandler(LifecycleEvents.TAGS.preFlatten(RegistryKey.ENCHANTMENT).newHandler((event) -> {
|
||||||
Set<TagEntry<Enchantment>> enchantTags = new HashSet<>(enchantioEnchants.size());
|
|
||||||
for (EnchantioEnchant enchant : enchantioEnchants) {
|
for (EnchantioEnchant enchant : enchantioEnchants) {
|
||||||
if (!enchant.canGetFromEnchantingTable()) continue;
|
enchant.getEnchantTagKeys().forEach(enchantmentTagKey -> {
|
||||||
logger.info("Registering enchantment " + enchant.getKey() + " to enchanting table possibilities");
|
logger.fine("Registering enchantment tag " + enchantmentTagKey.key());
|
||||||
enchantTags.add(enchant.getTagEntry());
|
event.registrar().addToTag(enchantmentTagKey, Set.of(enchant.getTagEntry()));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
event.registrar().addToTag(EnchantmentTagKeys.IN_ENCHANTING_TABLE, enchantTags);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,17 @@ 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 net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -19,9 +23,9 @@ 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 boolean canGetFromEnchantingTable;
|
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||||
private final double chanceToDropHeadPerLevel;
|
private final double chanceToDropHeadPerLevel;
|
||||||
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||||
|
|
||||||
public BeheadingEnchant(
|
public BeheadingEnchant(
|
||||||
int anvilCost,
|
int anvilCost,
|
||||||
@@ -37,10 +41,13 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.minimumCost = minimumCost;
|
this.minimumCost = minimumCost;
|
||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
|
||||||
this.supportedItemTags = supportedItemTags;
|
this.supportedItemTags = supportedItemTags;
|
||||||
this.maxLevel = maxLevel;
|
this.maxLevel = maxLevel;
|
||||||
this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel;
|
this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel;
|
||||||
|
|
||||||
|
if (canGetFromEnchantingTable) {
|
||||||
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -87,11 +94,6 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
|||||||
return Set.of(EquipmentSlotGroup.ANY);
|
return Set.of(EquipmentSlotGroup.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGetFromEnchantingTable() {
|
|
||||||
return canGetFromEnchantingTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TagKey<ItemType> getTagForSupportedItems() {
|
public TagKey<ItemType> getTagForSupportedItems() {
|
||||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:beheading_enchantable"));
|
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:beheading_enchantable"));
|
||||||
@@ -102,4 +104,9 @@ public class BeheadingEnchant implements EnchantioEnchant {
|
|||||||
return supportedItemTags;
|
return supportedItemTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||||
|
return Collections.unmodifiableSet(enchantTagKeys);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,14 @@ public interface EnchantioEnchant {
|
|||||||
|
|
||||||
Iterable<EquipmentSlotGroup> getActiveSlots();
|
Iterable<EquipmentSlotGroup> getActiveSlots();
|
||||||
|
|
||||||
boolean canGetFromEnchantingTable();
|
|
||||||
|
|
||||||
TagKey<ItemType> getTagForSupportedItems();
|
|
||||||
|
|
||||||
Set<TagEntry<ItemType>> getSupportedItems();
|
Set<TagEntry<ItemType>> getSupportedItems();
|
||||||
|
|
||||||
|
Set<TagKey<Enchantment>> getEnchantTagKeys();
|
||||||
|
|
||||||
|
default TagKey<ItemType> getTagForSupportedItems() {
|
||||||
|
return TagKey.create(RegistryKey.ITEM, Key.key( getKey().asString() + "_enchantable"));
|
||||||
|
}
|
||||||
|
|
||||||
default TagEntry<Enchantment> getTagEntry() {
|
default TagEntry<Enchantment> getTagEntry() {
|
||||||
return TagEntry.valueEntry(TypedKey.create(RegistryKey.ENCHANTMENT, getKey()));
|
return TagEntry.valueEntry(TypedKey.create(RegistryKey.ENCHANTMENT, getKey()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,17 @@ 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 net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -19,9 +23,9 @@ 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 boolean canGetFromEnchantingTable;
|
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||||
private final double damageMultiplierPerLevel, maxDamageHpThreshold;
|
private final double damageMultiplierPerLevel, maxDamageHpThreshold;
|
||||||
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
public ExecutionerEnchant(
|
public ExecutionerEnchant(
|
||||||
@@ -39,11 +43,13 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.minimumCost = minimumCost;
|
this.minimumCost = minimumCost;
|
||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
|
||||||
this.supportedItemTags = supportedItemTags;
|
this.supportedItemTags = supportedItemTags;
|
||||||
this.maxLevel = maxLevel;
|
this.maxLevel = maxLevel;
|
||||||
this.damageMultiplierPerLevel = damageMultiplierPerLevel;
|
this.damageMultiplierPerLevel = damageMultiplierPerLevel;
|
||||||
this.maxDamageHpThreshold = maxDamageHpThreshold;
|
this.maxDamageHpThreshold = maxDamageHpThreshold;
|
||||||
|
if (canGetFromEnchantingTable) {
|
||||||
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,19 +100,14 @@ public class ExecutionerEnchant implements EnchantioEnchant {
|
|||||||
return Set.of(EquipmentSlotGroup.HAND);
|
return Set.of(EquipmentSlotGroup.HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGetFromEnchantingTable() {
|
|
||||||
return canGetFromEnchantingTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagKey<ItemType> getTagForSupportedItems() {
|
|
||||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:executioner_enchantable"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||||
return supportedItemTags;
|
return supportedItemTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||||
|
return Collections.unmodifiableSet(enchantTagKeys);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package me.youhavetrouble.enchantio.enchants;
|
package me.youhavetrouble.enchantio.enchants;
|
||||||
|
|
||||||
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 net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -19,8 +22,8 @@ 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 boolean canGetFromEnchantingTable;
|
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||||
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||||
|
|
||||||
public ReplantingEnchant(
|
public ReplantingEnchant(
|
||||||
int anvilCost,
|
int anvilCost,
|
||||||
@@ -34,8 +37,10 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.minimumCost = minimumCost;
|
this.minimumCost = minimumCost;
|
||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
|
||||||
this.supportedItemTags = supportedItemTags;
|
this.supportedItemTags = supportedItemTags;
|
||||||
|
if (canGetFromEnchantingTable) {
|
||||||
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,19 +83,14 @@ public class ReplantingEnchant implements EnchantioEnchant {
|
|||||||
return Set.of(EquipmentSlotGroup.HAND);
|
return Set.of(EquipmentSlotGroup.HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGetFromEnchantingTable() {
|
|
||||||
return canGetFromEnchantingTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagKey<ItemType> getTagForSupportedItems() {
|
|
||||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:replanting_enchantable"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||||
return supportedItemTags;
|
return supportedItemTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||||
|
return Collections.unmodifiableSet(enchantTagKeys);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package me.youhavetrouble.enchantio.enchants;
|
package me.youhavetrouble.enchantio.enchants;
|
||||||
|
|
||||||
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 net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -19,8 +22,8 @@ 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 boolean canGetFromEnchantingTable;
|
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||||
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||||
|
|
||||||
public SmeltingEnchant(
|
public SmeltingEnchant(
|
||||||
int anvilCost,
|
int anvilCost,
|
||||||
@@ -34,8 +37,10 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.minimumCost = minimumCost;
|
this.minimumCost = minimumCost;
|
||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
|
||||||
this.supportedItemTags = supportedItemTags;
|
this.supportedItemTags = supportedItemTags;
|
||||||
|
if (canGetFromEnchantingTable) {
|
||||||
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,19 +83,14 @@ public class SmeltingEnchant implements EnchantioEnchant {
|
|||||||
return Set.of(EquipmentSlotGroup.ANY);
|
return Set.of(EquipmentSlotGroup.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGetFromEnchantingTable() {
|
|
||||||
return canGetFromEnchantingTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagKey<ItemType> getTagForSupportedItems() {
|
|
||||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:smelting_enchantable"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||||
return supportedItemTags;
|
return supportedItemTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||||
|
return Collections.unmodifiableSet(enchantTagKeys);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package me.youhavetrouble.enchantio.enchants;
|
package me.youhavetrouble.enchantio.enchants;
|
||||||
|
|
||||||
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 net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -19,8 +22,8 @@ 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 boolean canGetFromEnchantingTable;
|
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||||
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||||
|
|
||||||
public SoulboundEnchant(
|
public SoulboundEnchant(
|
||||||
int anvilCost,
|
int anvilCost,
|
||||||
@@ -34,8 +37,10 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.minimumCost = minimumCost;
|
this.minimumCost = minimumCost;
|
||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
|
||||||
this.supportedItemTags = supportedItemTags;
|
this.supportedItemTags = supportedItemTags;
|
||||||
|
if (canGetFromEnchantingTable) {
|
||||||
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,19 +83,14 @@ public class SoulboundEnchant implements EnchantioEnchant {
|
|||||||
return Set.of(EquipmentSlotGroup.ANY);
|
return Set.of(EquipmentSlotGroup.ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGetFromEnchantingTable() {
|
|
||||||
return canGetFromEnchantingTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagKey<ItemType> getTagForSupportedItems() {
|
|
||||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:soulbound_enchantable"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||||
return supportedItemTags;
|
return supportedItemTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||||
|
return Collections.unmodifiableSet(enchantTagKeys);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
package me.youhavetrouble.enchantio.enchants;
|
package me.youhavetrouble.enchantio.enchants;
|
||||||
|
|
||||||
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 net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
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 java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings("UnstableApiUsage")
|
||||||
@@ -19,8 +22,8 @@ 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 boolean canGetFromEnchantingTable;
|
|
||||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||||
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||||
|
|
||||||
public TelepathyEnchant(
|
public TelepathyEnchant(
|
||||||
int anvilCost,
|
int anvilCost,
|
||||||
@@ -34,8 +37,10 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
|||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.minimumCost = minimumCost;
|
this.minimumCost = minimumCost;
|
||||||
this.maximumCost = maximumCost;
|
this.maximumCost = maximumCost;
|
||||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
|
||||||
this.supportedItemTags = supportedItemTags;
|
this.supportedItemTags = supportedItemTags;
|
||||||
|
if (canGetFromEnchantingTable) {
|
||||||
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -78,19 +83,14 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
|||||||
return Set.of(EquipmentSlotGroup.HAND);
|
return Set.of(EquipmentSlotGroup.HAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canGetFromEnchantingTable() {
|
|
||||||
return canGetFromEnchantingTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagKey<ItemType> getTagForSupportedItems() {
|
|
||||||
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:telepathy_enchantable"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||||
return supportedItemTags;
|
return supportedItemTags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||||
|
return Collections.unmodifiableSet(enchantTagKeys);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user