Class CustomEnchantment
java.lang.Object
org.bukkit.enchantments.Enchantment
com.github.imdabigboss.easydatapack.api.enchantments.CustomEnchantment
- All Implemented Interfaces:
net.kyori.adventure.key.Keyed,net.kyori.adventure.translation.Translatable,org.bukkit.Keyed
public class CustomEnchantment
extends org.bukkit.enchantments.Enchantment
This class represents a custom enchantment.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class represents a builder for creating custom enchantments. -
Field Summary
Fields inherited from class org.bukkit.enchantments.Enchantment
ARROW_DAMAGE, ARROW_FIRE, ARROW_INFINITE, ARROW_KNOCKBACK, BINDING_CURSE, CHANNELING, DAMAGE_ALL, DAMAGE_ARTHROPODS, DAMAGE_UNDEAD, DEPTH_STRIDER, DIG_SPEED, DURABILITY, FIRE_ASPECT, FROST_WALKER, IMPALING, KNOCKBACK, LOOT_BONUS_BLOCKS, LOOT_BONUS_MOBS, LOYALTY, LUCK, LURE, MENDING, MULTISHOT, OXYGEN, PIERCING, PROTECTION_ENVIRONMENTAL, PROTECTION_EXPLOSIONS, PROTECTION_FALL, PROTECTION_FIRE, PROTECTION_PROJECTILE, QUICK_CHARGE, RIPTIDE, SILK_TOUCH, SOUL_SPEED, SWEEPING_EDGE, SWIFT_SNEAK, THORNS, VANISHING_CURSE, WATER_WORKER -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEnchantItem(@NonNull org.bukkit.inventory.ItemStack item)Checks if the enchantment can be applied to an item.booleanconflictsWith(@NonNull org.bukkit.enchantments.Enchantment other)Checks if the enchantment conflicts with another.@NonNull net.kyori.adventure.text.ComponentdisplayName(int i)Gets the enchantment's display name by level.@NonNull StringformatEnchantmentName(int level)Gets the formatted name of the enchantment by level.@NonNull Set<org.bukkit.inventory.EquipmentSlot>Gets the enchantment's active slots.intgetAnvilMergeCost(int level)Gets the enchantment's anvil merge cost by level.@NonNull org.bukkit.inventory.ItemStackgetBook(int level)Creates an item stack of a book with the enchantment.floatgetDamageIncrease(int level, @NonNull org.bukkit.entity.EntityCategory entityCategory)Gets the encantment's damage increase by level and entity category.intgetEnchantmentLevel(org.bukkit.inventory.ItemStack item)Gets the level of the enchantment on an item.@Nullable Class<? extends org.bukkit.event.Listener>Gets the enchantment's event listener if it has one.@NonNull org.bukkit.enchantments.EnchantmentTargetGets the item types that the enchantment can be applied to.intGets the maximum level of the enchantment.@NonNull StringgetName()Gets the name of the enchantment.@NonNull StringGets the namespace key of the enchantment.@NonNull io.papermc.paper.enchantments.EnchantmentRarityGets the enchantment's rarity.intGets the starting level, or the minimum of the enchantment.intgetTradeCost(int level)Gets the enchantment's trade cost by level.booleanhasEnchantment(@NonNull org.bukkit.inventory.ItemStack item)Checks if an item has the enchantment.booleanisCursed()Gets if the enchantment is a curse.booleanGets if the enchantment is discoverable.booleanGets if the enchantment is tradeable.booleanGets if the enchantment is a treasure.@NonNull StringGets the enchantment's translation key.Methods inherited from class org.bukkit.enchantments.Enchantment
equals, getByKey, getByName, getKey, hashCode, isAcceptingRegistrations, registerEnchantment, stopAcceptingRegistrations, toString, valuesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.Keyed
key
-
Method Details
-
getName
Gets the name of the enchantment.- Specified by:
getNamein classorg.bukkit.enchantments.Enchantment- Returns:
- the name of the enchantment
-
getNamespace
Gets the namespace key of the enchantment.- Returns:
- the namespace key of the enchantment
-
getMaxLevel
public int getMaxLevel()Gets the maximum level of the enchantment.- Specified by:
getMaxLevelin classorg.bukkit.enchantments.Enchantment- Returns:
- the maximum level of the enchantment
-
getStartLevel
public int getStartLevel()Gets the starting level, or the minimum of the enchantment.- Specified by:
getStartLevelin classorg.bukkit.enchantments.Enchantment- Returns:
- the starting level of the enchantment
-
conflictsWith
public boolean conflictsWith(@NonNull org.bukkit.enchantments.Enchantment other)Checks if the enchantment conflicts with another.- Specified by:
conflictsWithin classorg.bukkit.enchantments.Enchantment- Parameters:
other- the other enchantment to check- Returns:
- true if the enchantment conflicts, false otherwise
-
canEnchantItem
public boolean canEnchantItem(@NonNull org.bukkit.inventory.ItemStack item)Checks if the enchantment can be applied to an item.- Specified by:
canEnchantItemin classorg.bukkit.enchantments.Enchantment- Parameters:
item- the item to check- Returns:
- true if the enchantment can be applied, false otherwise
-
getItemTarget
public @NonNull org.bukkit.enchantments.EnchantmentTarget getItemTarget()Gets the item types that the enchantment can be applied to.- Specified by:
getItemTargetin classorg.bukkit.enchantments.Enchantment- Returns:
- the item types that the enchantment can be applied to
-
isTreasure
public boolean isTreasure()Gets if the enchantment is a treasure.- Specified by:
isTreasurein classorg.bukkit.enchantments.Enchantment- Returns:
- true if the enchantment is a treasure, false otherwise
-
isCursed
public boolean isCursed()Gets if the enchantment is a curse.- Specified by:
isCursedin classorg.bukkit.enchantments.Enchantment- Returns:
- true if the enchantment is a curse, false otherwise
-
displayName
public @NonNull net.kyori.adventure.text.Component displayName(int i)Gets the enchantment's display name by level.- Specified by:
displayNamein classorg.bukkit.enchantments.Enchantment- Parameters:
i- the level of the enchantment- Returns:
- the enchantment's display name
-
isTradeable
public boolean isTradeable()Gets if the enchantment is tradeable.- Specified by:
isTradeablein classorg.bukkit.enchantments.Enchantment- Returns:
- true if the enchantment is tradeable, false otherwise
-
isDiscoverable
public boolean isDiscoverable()Gets if the enchantment is discoverable.- Specified by:
isDiscoverablein classorg.bukkit.enchantments.Enchantment- Returns:
- true if the enchantment is discoverable, false otherwise
-
getRarity
public @NonNull io.papermc.paper.enchantments.EnchantmentRarity getRarity()Gets the enchantment's rarity.- Specified by:
getRarityin classorg.bukkit.enchantments.Enchantment- Returns:
- the enchantment's rarity
-
getDamageIncrease
public float getDamageIncrease(int level, @NonNull org.bukkit.entity.EntityCategory entityCategory)Gets the encantment's damage increase by level and entity category.- Specified by:
getDamageIncreasein classorg.bukkit.enchantments.Enchantment- Parameters:
level- the level of the enchantmententityCategory- the entity category- Returns:
- the damage increase
-
getActiveSlots
Gets the enchantment's active slots.- Specified by:
getActiveSlotsin classorg.bukkit.enchantments.Enchantment- Returns:
- an empty set
-
translationKey
Gets the enchantment's translation key.- Returns:
- the enchantment's translation key
-
getAnvilMergeCost
public int getAnvilMergeCost(int level)Gets the enchantment's anvil merge cost by level.- Parameters:
level- the level of the enchantment- Returns:
- the anvil merge cost
-
getTradeCost
public int getTradeCost(int level)Gets the enchantment's trade cost by level.- Parameters:
level- the level of the enchantment- Returns:
- the trade cost
-
getEventListener
Gets the enchantment's event listener if it has one.- Returns:
- the enchantment's event listener
-
formatEnchantmentName
Gets the formatted name of the enchantment by level. For example, "Sharpness V".- Parameters:
level- the level of the enchantment- Returns:
- the formatted name of the enchantment
-
getBook
public @NonNull org.bukkit.inventory.ItemStack getBook(int level)Creates an item stack of a book with the enchantment.- Parameters:
level- the level of the enchantment- Returns:
- the item stack of the book
-
hasEnchantment
public boolean hasEnchantment(@NonNull org.bukkit.inventory.ItemStack item)Checks if an item has the enchantment.- Parameters:
item- the item to check- Returns:
- true if the item has the enchantment, false otherwise
-
getEnchantmentLevel
public int getEnchantmentLevel(org.bukkit.inventory.ItemStack item)Gets the level of the enchantment on an item.- Parameters:
item- the item to check- Returns:
- the level of the enchantment
-