Class EnchantmentDefinitionImpl
java.lang.Object
io.artificial.enchantments.internal.EnchantmentDefinitionImpl
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.artificial.enchantments.api.EnchantmentDefinition
EnchantmentDefinition.Builder, EnchantmentDefinition.Rarity -
Method Summary
Modifier and TypeMethodDescriptiondoublecalculateScaledValue(int level) Calculates the scaled value for a given level.booleanconflictsWith(@NotNull EnchantmentDefinition other) Checks if this enchantment conflicts with another.boolean@NotNull Set<org.bukkit.Material> Gets all materials this enchantment can be applied to.@NotNull Set<org.bukkit.NamespacedKey> Gets all enchantment keys that conflict with this one.@Nullable net.kyori.adventure.text.ComponentGets the optional description shown in lore.@NotNull net.kyori.adventure.text.ComponentGets the display name shown to players.@Nullable EnchantmentEffectHandlerGets the effect handler for this enchantment, if any.@NotNull org.bukkit.NamespacedKeygetKey()Gets the unique namespaced key for this enchantment.intGets the maximum valid level for this enchantment.intGets the minimum valid level for this enchantment.@NotNull EnchantmentDefinition.RarityGets the rarity tier of this enchantment.@NotNull LevelScalingGets the scaling formula for calculating effect values.inthashCode()booleanisApplicableTo(@NotNull org.bukkit.Material material) Checks if this enchantment can be applied to a specific material.booleanisApplicableTo(@NotNull org.bukkit.inventory.ItemStack item) Checks if this enchantment can be applied to an item.booleanisCurse()Checks if this is a curse enchantment.booleanChecks if this enchantment can be found in loot.booleanChecks if this enchantment can be traded with villagers.toString()
-
Method Details
-
getKey
@NotNull public @NotNull org.bukkit.NamespacedKey getKey()Description copied from interface:EnchantmentDefinitionGets the unique namespaced key for this enchantment.- Specified by:
getKeyin interfaceEnchantmentDefinition- Returns:
- the enchantment's key (never null)
-
getDisplayName
@NotNull public @NotNull net.kyori.adventure.text.Component getDisplayName()Description copied from interface:EnchantmentDefinitionGets the display name shown to players.- Specified by:
getDisplayNamein interfaceEnchantmentDefinition- Returns:
- the display name component (never null)
-
getDescription
@Nullable public @Nullable net.kyori.adventure.text.Component getDescription()Description copied from interface:EnchantmentDefinitionGets the optional description shown in lore.- Specified by:
getDescriptionin interfaceEnchantmentDefinition- Returns:
- the description component, or null if none
-
getMinLevel
public int getMinLevel()Description copied from interface:EnchantmentDefinitionGets the minimum valid level for this enchantment.- Specified by:
getMinLevelin interfaceEnchantmentDefinition- Returns:
- the minimum level (always >= 1)
-
getMaxLevel
public int getMaxLevel()Description copied from interface:EnchantmentDefinitionGets the maximum valid level for this enchantment.- Specified by:
getMaxLevelin interfaceEnchantmentDefinition- Returns:
- the maximum level (>= minLevel)
-
getScaling
Description copied from interface:EnchantmentDefinitionGets the scaling formula for calculating effect values.- Specified by:
getScalingin interfaceEnchantmentDefinition- Returns:
- the level scaling instance (never null)
-
getApplicableMaterials
Description copied from interface:EnchantmentDefinitionGets all materials this enchantment can be applied to.- Specified by:
getApplicableMaterialsin interfaceEnchantmentDefinition- Returns:
- set of applicable materials (never null)
-
isApplicableTo
public boolean isApplicableTo(@NotNull @NotNull org.bukkit.Material material) Description copied from interface:EnchantmentDefinitionChecks if this enchantment can be applied to a specific material.- Specified by:
isApplicableToin interfaceEnchantmentDefinition- 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:EnchantmentDefinitionChecks if this enchantment can be applied to an item.- Specified by:
isApplicableToin interfaceEnchantmentDefinition- 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:EnchantmentDefinitionChecks if this is a curse enchantment.- Specified by:
isCursein interfaceEnchantmentDefinition- Returns:
- true if the enchantment is a curse
-
isTradeable
public boolean isTradeable()Description copied from interface:EnchantmentDefinitionChecks if this enchantment can be traded with villagers.- Specified by:
isTradeablein interfaceEnchantmentDefinition- Returns:
- true if tradeable
-
isDiscoverable
public boolean isDiscoverable()Description copied from interface:EnchantmentDefinitionChecks if this enchantment can be found in loot.- Specified by:
isDiscoverablein interfaceEnchantmentDefinition- Returns:
- true if discoverable
-
getRarity
Description copied from interface:EnchantmentDefinitionGets the rarity tier of this enchantment.- Specified by:
getRarityin interfaceEnchantmentDefinition- Returns:
- the rarity (never null)
-
getEffectHandler
Description copied from interface:EnchantmentDefinitionGets the effect handler for this enchantment, if any.- Specified by:
getEffectHandlerin interfaceEnchantmentDefinition- Returns:
- the effect handler, or null if this enchantment has no effects
-
calculateScaledValue
public double calculateScaledValue(int level) Description copied from interface:EnchantmentDefinitionCalculates the scaled value for a given level.Uses the configured
LevelScalingformula.- Specified by:
calculateScaledValuein interfaceEnchantmentDefinition- Parameters:
level- the enchantment level to calculate for- Returns:
- the scaled value
-
conflictsWith
Description copied from interface:EnchantmentDefinitionChecks if this enchantment conflicts with another.- Specified by:
conflictsWithin interfaceEnchantmentDefinition- Parameters:
other- the other enchantment to check (must not be null)- Returns:
- true if the enchantments cannot coexist on the same item
-
getConflictingEnchantments
Description copied from interface:EnchantmentDefinitionGets all enchantment keys that conflict with this one.- Specified by:
getConflictingEnchantmentsin interfaceEnchantmentDefinition- Returns:
- set of conflicting enchantment keys (never null)
-
equals
-
hashCode
public int hashCode() -
toString
-