mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-12 06:06:55 +00:00
refactor to allow adding enchants to arbitrary tags
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
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 net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlotGroup;
|
||||
import org.bukkit.inventory.ItemType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@@ -19,8 +22,8 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
private final int anvilCost, weight;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
||||
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
||||
private final boolean canGetFromEnchantingTable;
|
||||
private final Set<TagEntry<ItemType>> supportedItemTags;
|
||||
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
||||
|
||||
public TelepathyEnchant(
|
||||
int anvilCost,
|
||||
@@ -34,8 +37,10 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
this.weight = weight;
|
||||
this.minimumCost = minimumCost;
|
||||
this.maximumCost = maximumCost;
|
||||
this.canGetFromEnchantingTable = canGetFromEnchantingTable;
|
||||
this.supportedItemTags = supportedItemTags;
|
||||
if (canGetFromEnchantingTable) {
|
||||
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,19 +83,14 @@ public class TelepathyEnchant implements EnchantioEnchant {
|
||||
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
|
||||
public Set<TagEntry<ItemType>> getSupportedItems() {
|
||||
return supportedItemTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
||||
return Collections.unmodifiableSet(enchantTagKeys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user