add ability to configure active slots for the enchant

This commit is contained in:
2024-10-30 16:19:48 +01:00
parent 5ff3821cb3
commit 536c074439
10 changed files with 149 additions and 68 deletions
@@ -9,6 +9,7 @@ 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;
@@ -25,6 +26,7 @@ public class PanicEnchant implements EnchantioEnchant {
private final double panicChancePerLevel;
private final Set<TagEntry<ItemType>> supportedItemTags;
private final Set<TagKey<Enchantment>> enchantTagKeys = new HashSet<>();
private final Set<EquipmentSlotGroup> activeSlots = new HashSet<>();
public PanicEnchant(
int anvilCost,
@@ -33,6 +35,7 @@ public class PanicEnchant implements EnchantioEnchant {
EnchantmentRegistryEntry.EnchantmentCost maximumCost,
boolean canGetFromEnchantingTable,
Set<TagEntry<ItemType>> supportedItemTags,
Set<EquipmentSlotGroup> activeSlots,
int maxLevel,
double panicChancePerLevel
) {
@@ -43,6 +46,7 @@ public class PanicEnchant implements EnchantioEnchant {
this.maximumCost = maximumCost;
this.supportedItemTags = supportedItemTags;
this.panicChancePerLevel = panicChancePerLevel;
this.activeSlots.addAll(activeSlots);
if (canGetFromEnchantingTable) {
enchantTagKeys.add(EnchantmentTagKeys.IN_ENCHANTING_TABLE);
}
@@ -50,12 +54,12 @@ public class PanicEnchant implements EnchantioEnchant {
}
@Override
public Key getKey() {
public @NotNull Key getKey() {
return KEY;
}
@Override
public Component getDescription() {
public @NotNull Component getDescription() {
return Component.translatable("enchantio.enchant.panic_curse", "Curse of Panic");
}
@@ -75,27 +79,27 @@ public class PanicEnchant implements EnchantioEnchant {
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMinimumCost() {
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMinimumCost() {
return minimumCost;
}
@Override
public EnchantmentRegistryEntry.EnchantmentCost getMaximumCost() {
public EnchantmentRegistryEntry.@NotNull EnchantmentCost getMaximumCost() {
return maximumCost;
}
@Override
public Iterable<EquipmentSlotGroup> getActiveSlots() {
return Set.of(EquipmentSlotGroup.ARMOR);
public @NotNull Iterable<EquipmentSlotGroup> getActiveSlots() {
return activeSlots;
}
@Override
public Set<TagEntry<ItemType>> getSupportedItems() {
public @NotNull Set<TagEntry<ItemType>> getSupportedItems() {
return supportedItemTags;
}
@Override
public Set<TagKey<Enchantment>> getEnchantTagKeys() {
public @NotNull Set<TagKey<Enchantment>> getEnchantTagKeys() {
return Collections.unmodifiableSet(enchantTagKeys);
}