Class EnchantmentDefinitionImpl

java.lang.Object
io.artificial.enchantments.internal.EnchantmentDefinitionImpl
All Implemented Interfaces:
EnchantmentDefinition

public final class EnchantmentDefinitionImpl extends Object implements EnchantmentDefinition
Immutable implementation of EnchantmentDefinition.

This class is instantiated by EnchantmentDefinitionBuilder and provides thread-safe, immutable access to all enchantment properties.

Since:
0.2.0
  • Method Details

    • getKey

      @NotNull public @NotNull org.bukkit.NamespacedKey getKey()
      Description copied from interface: EnchantmentDefinition
      Gets the unique namespaced key for this enchantment.
      Specified by:
      getKey in interface EnchantmentDefinition
      Returns:
      the enchantment's key (never null)
    • getDisplayName

      @NotNull public @NotNull net.kyori.adventure.text.Component getDisplayName()
      Description copied from interface: EnchantmentDefinition
      Gets the display name shown to players.
      Specified by:
      getDisplayName in interface EnchantmentDefinition
      Returns:
      the display name component (never null)
    • getDescription

      @Nullable public @Nullable net.kyori.adventure.text.Component getDescription()
      Description copied from interface: EnchantmentDefinition
      Gets the optional description shown in lore.
      Specified by:
      getDescription in interface EnchantmentDefinition
      Returns:
      the description component, or null if none
    • getMinLevel

      public int getMinLevel()
      Description copied from interface: EnchantmentDefinition
      Gets the minimum valid level for this enchantment.
      Specified by:
      getMinLevel in interface EnchantmentDefinition
      Returns:
      the minimum level (always >= 1)
    • getMaxLevel

      public int getMaxLevel()
      Description copied from interface: EnchantmentDefinition
      Gets the maximum valid level for this enchantment.
      Specified by:
      getMaxLevel in interface EnchantmentDefinition
      Returns:
      the maximum level (>= minLevel)
    • getScaling

      @NotNull public @NotNull LevelScaling getScaling()
      Description copied from interface: EnchantmentDefinition
      Gets the scaling formula for calculating effect values.
      Specified by:
      getScaling in interface EnchantmentDefinition
      Returns:
      the level scaling instance (never null)
    • getApplicableMaterials

      @NotNull public @NotNull Set<org.bukkit.Material> getApplicableMaterials()
      Description copied from interface: EnchantmentDefinition
      Gets all materials this enchantment can be applied to.
      Specified by:
      getApplicableMaterials in interface EnchantmentDefinition
      Returns:
      set of applicable materials (never null)
    • isApplicableTo

      public boolean isApplicableTo(@NotNull @NotNull org.bukkit.Material material)
      Description copied from interface: EnchantmentDefinition
      Checks if this enchantment can be applied to a specific material.
      Specified by:
      isApplicableTo in interface EnchantmentDefinition
      Parameters:
      material - the material to check (must not be null)
      Returns:
      true if applicable
    • isApplicableTo

      public boolean isApplicableTo(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Description copied from interface: EnchantmentDefinition
      Checks if this enchantment can be applied to an item.
      Specified by:
      isApplicableTo in interface EnchantmentDefinition
      Parameters:
      item - the item to check (must not be null)
      Returns:
      true if applicable to the item's material
    • isCurse

      public boolean isCurse()
      Description copied from interface: EnchantmentDefinition
      Checks if this is a curse enchantment.
      Specified by:
      isCurse in interface EnchantmentDefinition
      Returns:
      true if the enchantment is a curse
    • isTradeable

      public boolean isTradeable()
      Description copied from interface: EnchantmentDefinition
      Checks if this enchantment can be traded with villagers.
      Specified by:
      isTradeable in interface EnchantmentDefinition
      Returns:
      true if tradeable
    • isDiscoverable

      public boolean isDiscoverable()
      Description copied from interface: EnchantmentDefinition
      Checks if this enchantment can be found in loot.
      Specified by:
      isDiscoverable in interface EnchantmentDefinition
      Returns:
      true if discoverable
    • getRarity

      @NotNull public @NotNull EnchantmentDefinition.Rarity getRarity()
      Description copied from interface: EnchantmentDefinition
      Gets the rarity tier of this enchantment.
      Specified by:
      getRarity in interface EnchantmentDefinition
      Returns:
      the rarity (never null)
    • getEffectHandler

      @Nullable public @Nullable EnchantmentEffectHandler getEffectHandler()
      Description copied from interface: EnchantmentDefinition
      Gets the effect handler for this enchantment, if any.
      Specified by:
      getEffectHandler in interface EnchantmentDefinition
      Returns:
      the effect handler, or null if this enchantment has no effects
    • calculateScaledValue

      public double calculateScaledValue(int level)
      Description copied from interface: EnchantmentDefinition
      Calculates the scaled value for a given level.

      Uses the configured LevelScaling formula.

      Specified by:
      calculateScaledValue in interface EnchantmentDefinition
      Parameters:
      level - the enchantment level to calculate for
      Returns:
      the scaled value
    • conflictsWith

      public boolean conflictsWith(@NotNull @NotNull EnchantmentDefinition other)
      Description copied from interface: EnchantmentDefinition
      Checks if this enchantment conflicts with another.
      Specified by:
      conflictsWith in interface EnchantmentDefinition
      Parameters:
      other - the other enchantment to check (must not be null)
      Returns:
      true if the enchantments cannot coexist on the same item
    • getConflictingEnchantments

      @NotNull public @NotNull Set<org.bukkit.NamespacedKey> getConflictingEnchantments()
      Description copied from interface: EnchantmentDefinition
      Gets all enchantment keys that conflict with this one.
      Specified by:
      getConflictingEnchantments in interface EnchantmentDefinition
      Returns:
      set of conflicting enchantment keys (never null)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object