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 Classes
    Modifier and Type
    Class
    Description
    static class 
    This 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 Type
    Method
    Description
    boolean
    canEnchantItem​(@NonNull org.bukkit.inventory.ItemStack item)
    Checks if the enchantment can be applied to an item.
    boolean
    conflictsWith​(@NonNull org.bukkit.enchantments.Enchantment other)
    Checks if the enchantment conflicts with another.
    @NonNull net.kyori.adventure.text.Component
    displayName​(int i)
    Gets the enchantment's display name by level.
    @NonNull String
    formatEnchantmentName​(int level)
    Gets the formatted name of the enchantment by level.
    @NonNull Set<org.bukkit.inventory.EquipmentSlot>
    Gets the enchantment's active slots.
    int
    getAnvilMergeCost​(int level)
    Gets the enchantment's anvil merge cost by level.
    @NonNull org.bukkit.inventory.ItemStack
    getBook​(int level)
    Creates an item stack of a book with the enchantment.
    float
    getDamageIncrease​(int level, @NonNull org.bukkit.entity.EntityCategory entityCategory)
    Gets the encantment's damage increase by level and entity category.
    int
    getEnchantmentLevel​(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.EnchantmentTarget
    Gets the item types that the enchantment can be applied to.
    int
    Gets the maximum level of the enchantment.
    @NonNull String
    Gets the name of the enchantment.
    @NonNull String
    Gets the namespace key of the enchantment.
    @NonNull io.papermc.paper.enchantments.EnchantmentRarity
    Gets the enchantment's rarity.
    int
    Gets the starting level, or the minimum of the enchantment.
    int
    getTradeCost​(int level)
    Gets the enchantment's trade cost by level.
    boolean
    hasEnchantment​(@NonNull org.bukkit.inventory.ItemStack item)
    Checks if an item has the enchantment.
    boolean
    Gets if the enchantment is a curse.
    boolean
    Gets if the enchantment is discoverable.
    boolean
    Gets if the enchantment is tradeable.
    boolean
    Gets if the enchantment is a treasure.
    @NonNull String
    Gets the enchantment's translation key.

    Methods inherited from class org.bukkit.enchantments.Enchantment

    equals, getByKey, getByName, getKey, hashCode, isAcceptingRegistrations, registerEnchantment, stopAcceptingRegistrations, toString, values

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.Keyed

    key
  • Method Details

    • getName

      public @NonNull String getName()
      Gets the name of the enchantment.
      Specified by:
      getName in class org.bukkit.enchantments.Enchantment
      Returns:
      the name of the enchantment
    • getNamespace

      public @NonNull String 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:
      getMaxLevel in class org.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:
      getStartLevel in class org.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:
      conflictsWith in class org.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:
      canEnchantItem in class org.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:
      getItemTarget in class org.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:
      isTreasure in class org.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:
      isCursed in class org.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:
      displayName in class org.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:
      isTradeable in class org.bukkit.enchantments.Enchantment
      Returns:
      true if the enchantment is tradeable, false otherwise
    • isDiscoverable

      public boolean isDiscoverable()
      Gets if the enchantment is discoverable.
      Specified by:
      isDiscoverable in class org.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:
      getRarity in class org.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:
      getDamageIncrease in class org.bukkit.enchantments.Enchantment
      Parameters:
      level - the level of the enchantment
      entityCategory - the entity category
      Returns:
      the damage increase
    • getActiveSlots

      public @NonNull Set<org.bukkit.inventory.EquipmentSlot> getActiveSlots()
      Gets the enchantment's active slots.
      Specified by:
      getActiveSlots in class org.bukkit.enchantments.Enchantment
      Returns:
      an empty set
    • translationKey

      public @NonNull String 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

      @Nullable public @Nullable Class<? extends org.bukkit.event.Listener> getEventListener()
      Gets the enchantment's event listener if it has one.
      Returns:
      the enchantment's event listener
    • formatEnchantmentName

      public @NonNull String formatEnchantmentName(int level)
      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