mirror of
https://github.com/YouHaveTrouble/Enchantio.git
synced 2026-05-11 21:56:55 +00:00
116 lines
3.5 KiB
Java
116 lines
3.5 KiB
Java
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 org.jetbrains.annotations.NotNull;
|
|
|
|
import java.util.Collections;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
@SuppressWarnings("UnstableApiUsage")
|
|
public class BeheadingEnchant implements EnchantioEnchant {
|
|
|
|
public static final Key KEY = Key.key("enchantio:beheading");
|
|
|
|
private final int anvilCost, weight, maxLevel;
|
|
private final EnchantmentRegistryEntry.EnchantmentCost minimumCost;
|
|
private final EnchantmentRegistryEntry.EnchantmentCost maximumCost;
|
|
private final Set<TagEntry<ItemType>> supportedItemTags;
|
|
private final double chanceToDropHeadPerLevel;
|
|
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
|
|
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
|
|
|
|
public BeheadingEnchant(
|
|
int anvilCost,
|
|
int weight,
|
|
EnchantmentRegistryEntry.EnchantmentCost minimumCost,
|
|
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
|
|
boolean canGetFromEnchantingTable,
|
|
Set<TagEntry<ItemType>> supportedItemTags,
|
|
Set<EquipmentSlotGroup> activeSlots,
|
|
int maxLevel,
|
|
double chanceToDropHeadPerLevel
|
|
) {
|
|
this.anvilCost = anvilCost;
|
|
this.weight = weight;
|
|
this.minimumCost = minimumCost;
|
|
this.maximumCost = maximumCost;
|
|
this.supportedItemTags = supportedItemTags;
|
|
this.maxLevel = maxLevel;
|
|
this.chanceToDropHeadPerLevel = chanceToDropHeadPerLevel;
|
|
this.activeSlots.addAll(activeSlots);
|
|
if (canGetFromEnchantingTable) {
|
|
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Key getKey() {
|
|
return KEY;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Component getDescription() {
|
|
return Component.translatable("enchantio.enchant.beheading", "Beheading");
|
|
}
|
|
|
|
@Override
|
|
public int getAnvilCost() {
|
|
return anvilCost;
|
|
}
|
|
|
|
@Override
|
|
public int getMaxLevel() {
|
|
return maxLevel;
|
|
}
|
|
|
|
public double getChanceToDropHeadPerLevel() {
|
|
return chanceToDropHeadPerLevel;
|
|
}
|
|
|
|
@Override
|
|
public int getWeight() {
|
|
return weight;
|
|
}
|
|
|
|
@Override
|
|
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
|
|
return minimumCost;
|
|
}
|
|
|
|
@Override
|
|
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
|
|
return maximumCost;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
|
|
return activeSlots;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull TagKey<ItemType> getTagForSupportedItems() {
|
|
return TagKey.create(RegistryKey.ITEM, Key.key("enchantio:beheading_enchantable"));
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
|
|
return supportedItemTags;
|
|
}
|
|
|
|
@Override
|
|
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
|
|
return Collections.unmodifiableSet(enchantTagKeys);
|
|
}
|
|
|
|
}
|