Class CustomEnchantment

java.lang.Object
studio.magemonkey.fabled.enchants.api.CustomEnchantment
All Implemented Interfaces:
Comparable<CustomEnchantment>
Direct Known Subclasses:
SkillEnchantment, VanillaEnchantment

public abstract class CustomEnchantment extends Object implements Comparable<CustomEnchantment>
FabledEnchants © 2026 VoidEdge api.studio.magemonkey.fabled.enchants.CustomEnchantment
  • Field Details

    • DEFAULT_GROUP

      public static final String DEFAULT_GROUP
      Default conflict group for enchantments. Using this group causes the enchantment not to conflict with any other enchantments.
      See Also:
    • settings

      protected Settings settings
  • Constructor Details

    • CustomEnchantment

      protected CustomEnchantment(String name, String description)
  • Method Details

    • getName

      public String getName()
      Returns:
      name of the enchantment that shows up in the lore
    • getDescription

      public String getDescription()
      Returns:
      details for the enchantment to show in the details book
    • canStack

      public boolean canStack()
      Returns:
      whether or not having the enchantment on multiple items stacks their effects
    • setCanStack

      public void setCanStack(boolean stacks)
      See Also:
    • isEnabled

      public boolean isEnabled()
      Returns:
      whether or not the enchantment is obtainable without commands
    • isTableEnabled

      public boolean isTableEnabled()
      Returns:
      whether or not the enchantment is obtainable
    • setTableEnabled

      public void setTableEnabled(boolean tableEnabled)
      See Also:
    • getMaxLevel

      public int getMaxLevel()
      Returns:
      the max level the enchantment can normally reach via combining enchantments
    • getMaxTableLevel

      public int getMaxTableLevel()
      Returns:
      the max level the enchantment can be from an enchanting table
    • setMaxLevel

      public void setMaxLevel(int maxLevel)
      Sets both the max table level and combine level to the given amount.
      Parameters:
      maxLevel - max normally obtainable level
    • setMaxLevel

      public void setMaxLevel(int maxLevel, int maxTableLevel)
      See Also:
    • getMinEnchantingLevel

      public double getMinEnchantingLevel()
      Note: modified enchantment level is normally between 2 and 48
      Returns:
      minimum modified enchantment level needed to receive this enchantment
    • setMinEnchantingLevel

      public void setMinEnchantingLevel(double minEnchantingLevel)
    • getEnchantLevelScaleFactor

      public double getEnchantLevelScaleFactor()
    • setEnchantLevelScaleFactor

      public void setEnchantLevelScaleFactor(double enchantLevelScaleFactor)
    • getEnchantLevelBuffer

      public double getEnchantLevelBuffer()
    • setEnchantLevelBuffer

      public void setEnchantLevelBuffer(double enchantLevelBuffer)
    • getCombineCostPerLevel

      public int getCombineCostPerLevel()
    • setCombineCostPerLevel

      public void setCombineCostPerLevel(int combineCostPerLevel)
    • getNaturalItems

      public Set<org.bukkit.Material> getNaturalItems()
    • addNaturalItems

      public void addNaturalItems(org.bukkit.Material... materials)
    • getAnvilItems

      public Set<org.bukkit.Material> getAnvilItems()
    • addAnvilItems

      public void addAnvilItems(org.bukkit.Material... materials)
    • getWeight

      public double getWeight(org.bukkit.Material material)
    • setWeight

      public void setWeight(double weight)
    • setWeight

      public void setWeight(org.bukkit.Material material, double weight)
    • getGroup

      public String getGroup()
    • setGroup

      public void setGroup(String group)
    • computeLevel

      public int computeLevel(int expLevel)
      Parameters:
      expLevel - enchanting level (from enchanting table)
      Returns:
      enchantment level
    • canEnchantOnto

      public boolean canEnchantOnto(org.bukkit.inventory.ItemStack item)
      Parameters:
      item - item to check
      Returns:
      true if can go onto the item, not including conflicts with other enchantments
    • canMergeOnto

      public boolean canMergeOnto(org.bukkit.inventory.ItemStack item)
      Parameters:
      item - item to check
      Returns:
      true if can merge onto the item, not including conflicts with other enchantments
    • conflictsWith

      public boolean conflictsWith(CustomEnchantment other, boolean same)
      Checks whether or not this enchantment works with the given enchantment
      Parameters:
      other - enchantment to check against
      same - whether or not to allow the same enchantment (in case of merging)
      Returns:
      true if there is a conflict, false otherwise
    • conflictsWith

      public boolean conflictsWith(List<CustomEnchantment> enchantments, boolean same)
      Checks whether or not this enchantment works with all of the given enchantments
      Parameters:
      enchantments - enchantments to check against
      same - whether or not to allow the same enchantment (in case of merging)
      Returns:
      true if there is a conflict, false otherwise
    • conflictsWith

      public boolean conflictsWith(boolean same, CustomEnchantment... enchantments)
      Checks whether or not this enchantment works with all of the given enchantments
      Parameters:
      same - whether or not to allow the same enchantment (in case of merging)
      enchantments - enchantments to check against
      Returns:
      true if there is a conflict, false otherwise
    • addToItem

      public org.bukkit.inventory.ItemStack addToItem(org.bukkit.inventory.ItemStack item, int level)
      Parameters:
      item - item to add to
      level - enchantment level
      Returns:
      item with the enchantment
    • removeFromItem

      public org.bukkit.inventory.ItemStack removeFromItem(org.bukkit.inventory.ItemStack item)
      Parameters:
      item - item to remove from
      Returns:
      item without this enchantment
    • addToEnchantment

      public void addToEnchantment(Map<org.bukkit.enchantments.Enchantment,Integer> enchantments, org.bukkit.inventory.ItemStack result, int level)
    • hasPermission

      public boolean hasPermission(org.bukkit.permissions.Permissible permissible)
      Parameters:
      permissible - person to receive the enchantment
      Returns:
      true if they have permission, false otherwise
    • getPermission

      public String getPermission()
      Returns:
      permission used by the enchantment
    • applyOnHit

      public void applyOnHit(org.bukkit.entity.LivingEntity user, org.bukkit.entity.LivingEntity target, int level, org.bukkit.event.entity.EntityDamageByEntityEvent event)
      Applies the enchantment affect when attacking someone
      Parameters:
      user - the entity that has the enchantment
      target - the entity that was struck by the enchantment
      level - the level of the used enchantment
      event - the event details
    • applyDefense

      public void applyDefense(org.bukkit.entity.LivingEntity user, org.bukkit.entity.LivingEntity target, int level, org.bukkit.event.entity.EntityDamageEvent event)
      Applies the enchantment defensively (when taking damage)
      Parameters:
      user - the entity hat has the enchantment
      target - the entity that attacked the enchantment, can be null
      level - the level of the used enchantment
      event - the event details (EntityDamageByEntityEvent, EntityDamageByBlockEvent, or just EntityDamageEvent)
    • applyBreak

      public void applyBreak(org.bukkit.entity.LivingEntity user, org.bukkit.block.Block block, int level, org.bukkit.event.block.BlockEvent event)
      Applies effects while breaking blocks (for tool effects)
      Parameters:
      user - the player with the enchantment
      block - the block being broken
      event - the event details (either BlockBreakEvent or BlockDamageEvent)
    • applyEquip

      public void applyEquip(org.bukkit.entity.LivingEntity user, int level)
      Applies effects when the item is equipped
      Parameters:
      user - the player that equipped it
      level - the level of enchantment
    • applyUnequip

      public void applyUnequip(org.bukkit.entity.LivingEntity user, int level)
      Applies effects when the item is unequipped
      Parameters:
      user - the player that unequipped it
      level - the level of enchantment
    • applyInteractBlock

      public void applyInteractBlock(org.bukkit.entity.Player user, int level, org.bukkit.event.player.PlayerInteractEvent event)
      Applies effects when the player left or right clicks (For other kinds of enchantments like spells)
      Parameters:
      user - the player with the enchantment
      event - the event details
    • applyInteractEntity

      public void applyInteractEntity(org.bukkit.entity.Player user, int level, org.bukkit.event.player.PlayerInteractEntityEvent event)
      Applies effects when the player interacts with an entity
      Parameters:
      user - player with the enchantment
      level - enchantment level
      event - the event details
    • applyProjectile

      public void applyProjectile(org.bukkit.entity.LivingEntity user, int level, org.bukkit.event.entity.ProjectileLaunchEvent event)
      Applies effects when firing a projectile
      Parameters:
      user - entity firing the projectile
      level - enchantment level
      event - the event details
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

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

      public int compareTo(CustomEnchantment other)
      Specified by:
      compareTo in interface Comparable<CustomEnchantment>
    • getSaveFolder

      protected String getSaveFolder()
    • save

      public void save(FabledEnchants plugin)
    • load

      public void load(FabledEnchants plugin)