Class CustomEnchantment
java.lang.Object
studio.magemonkey.fabled.enchants.api.CustomEnchantment
- All Implemented Interfaces:
Comparable<CustomEnchantment>
- Direct Known Subclasses:
SkillEnchantment,VanillaEnchantment
FabledEnchants © 2026 VoidEdge
api.studio.magemonkey.fabled.enchants.CustomEnchantment
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnvilItems(org.bukkit.Material... materials) voidaddNaturalItems(org.bukkit.Material... materials) voidaddToEnchantment(Map<org.bukkit.enchantments.Enchantment, Integer> enchantments, org.bukkit.inventory.ItemStack result, int level) org.bukkit.inventory.ItemStackaddToItem(org.bukkit.inventory.ItemStack item, int level) voidapplyBreak(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)voidapplyDefense(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)voidapplyEquip(org.bukkit.entity.LivingEntity user, int level) Applies effects when the item is equippedvoidapplyInteractBlock(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)voidapplyInteractEntity(org.bukkit.entity.Player user, int level, org.bukkit.event.player.PlayerInteractEntityEvent event) Applies effects when the player interacts with an entityvoidapplyOnHit(org.bukkit.entity.LivingEntity user, org.bukkit.entity.LivingEntity target, int level, org.bukkit.event.entity.EntityDamageByEntityEvent event) Applies the enchantment affect when attacking someonevoidapplyProjectile(org.bukkit.entity.LivingEntity user, int level, org.bukkit.event.entity.ProjectileLaunchEvent event) Applies effects when firing a projectilevoidapplyUnequip(org.bukkit.entity.LivingEntity user, int level) Applies effects when the item is unequippedbooleancanEnchantOnto(org.bukkit.inventory.ItemStack item) booleancanMergeOnto(org.bukkit.inventory.ItemStack item) booleancanStack()intcompareTo(CustomEnchantment other) intcomputeLevel(int expLevel) booleanconflictsWith(boolean same, CustomEnchantment... enchantments) Checks whether or not this enchantment works with all of the given enchantmentsbooleanconflictsWith(List<CustomEnchantment> enchantments, boolean same) Checks whether or not this enchantment works with all of the given enchantmentsbooleanconflictsWith(CustomEnchantment other, boolean same) Checks whether or not this enchantment works with the given enchantmentbooleanSet<org.bukkit.Material> intdoubledoublegetGroup()intintdoubleNote: modified enchantment level is normally between 2 and 48getName()Set<org.bukkit.Material> protected StringdoublegetWeight(org.bukkit.Material material) inthashCode()booleanhasPermission(org.bukkit.permissions.Permissible permissible) booleanbooleanvoidload(FabledEnchants plugin) org.bukkit.inventory.ItemStackremoveFromItem(org.bukkit.inventory.ItemStack item) voidsave(FabledEnchants plugin) voidsetCanStack(boolean stacks) voidsetCombineCostPerLevel(int combineCostPerLevel) voidsetEnchantLevelBuffer(double enchantLevelBuffer) voidsetEnchantLevelScaleFactor(double enchantLevelScaleFactor) voidvoidsetMaxLevel(int maxLevel) Sets both the max table level and combine level to the given amount.voidsetMaxLevel(int maxLevel, int maxTableLevel) voidsetMinEnchantingLevel(double minEnchantingLevel) voidsetTableEnabled(boolean tableEnabled) voidsetWeight(double weight) voidsetWeight(org.bukkit.Material material, double weight) toString()
-
Field Details
-
DEFAULT_GROUP
Default conflict group for enchantments. Using this group causes the enchantment not to conflict with any other enchantments.- See Also:
-
settings
-
-
Constructor Details
-
CustomEnchantment
-
-
Method Details
-
getName
- Returns:
- name of the enchantment that shows up in the lore
-
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
-
addNaturalItems
public void addNaturalItems(org.bukkit.Material... materials) -
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
-
setGroup
-
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
Checks whether or not this enchantment works with the given enchantment- Parameters:
other- enchantment to check againstsame- whether or not to allow the same enchantment (in case of merging)- Returns:
- true if there is a conflict, false otherwise
-
conflictsWith
Checks whether or not this enchantment works with all of the given enchantments- Parameters:
enchantments- enchantments to check againstsame- whether or not to allow the same enchantment (in case of merging)- Returns:
- true if there is a conflict, false otherwise
-
conflictsWith
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 tolevel- 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
-
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
- 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 enchantmenttarget- the entity that was struck by the enchantmentlevel- the level of the used enchantmentevent- 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 enchantmenttarget- the entity that attacked the enchantment, can be nulllevel- the level of the used enchantmentevent- 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 enchantmentblock- the block being brokenevent- 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 itlevel- 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 itlevel- 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 enchantmentevent- 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 enchantmentlevel- enchantment levelevent- 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 projectilelevel- enchantment levelevent- the event details
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<CustomEnchantment>
-
getSaveFolder
-
save
-
load
-