Class Enchantment

java.lang.Object
org.bukkit.enchantments.Enchantment
Direct Known Subclasses:
EnchantmentWrapper

public abstract class Enchantment
extends java.lang.Object
The various type of enchantments that may be added to armour or weapons
  • Field Details

  • Constructor Details

  • Method Details

    • getId

      @Deprecated public int getId()
      Deprecated.
      Magic value
      Gets the unique ID of this enchantment
      Returns:
      Unique ID
    • getName

      public abstract java.lang.String getName()
      Gets the unique name of this enchantment
      Returns:
      Unique name
    • getMaxLevel

      public abstract int getMaxLevel()
      Gets the maximum level that this Enchantment may become.
      Returns:
      Maximum level of the Enchantment
    • getStartLevel

      public abstract int getStartLevel()
      Gets the level that this Enchantment should start at
      Returns:
      Starting level of the Enchantment
    • getItemTarget

      public abstract EnchantmentTarget getItemTarget()
      Gets the type of ItemStack that may fit this Enchantment.
      Returns:
      Target type of the Enchantment
    • conflictsWith

      public abstract boolean conflictsWith​(Enchantment other)
      Check if this enchantment conflicts with another enchantment.
      Parameters:
      other - The enchantment to check against
      Returns:
      True if there is a conflict.
    • canEnchantItem

      public abstract boolean canEnchantItem​(ItemStack item)
      Checks if this Enchantment may be applied to the given ItemStack.

      This does not check if it conflicts with any enchantments already applied to the item.

      Parameters:
      item - Item to test
      Returns:
      True if the enchantment may be applied, otherwise False
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • registerEnchantment

      public static void registerEnchantment​(Enchantment enchantment)
      Registers an enchantment with the given ID and object.

      Generally not to be used from within a plugin.

      Parameters:
      enchantment - Enchantment to register
    • isAcceptingRegistrations

      public static boolean isAcceptingRegistrations()
      Checks if this is accepting Enchantment registrations.
      Returns:
      True if the server Implementation may add enchantments
    • stopAcceptingRegistrations

      public static void stopAcceptingRegistrations()
      Stops accepting any enchantment registrations
    • getById

      @Deprecated public static Enchantment getById​(int id)
      Deprecated.
      Magic value
      Gets the Enchantment at the specified ID
      Parameters:
      id - ID to fetch
      Returns:
      Resulting Enchantment, or null if not found
    • getByName

      public static Enchantment getByName​(java.lang.String name)
      Gets the Enchantment at the specified name
      Parameters:
      name - Name to fetch
      Returns:
      Resulting Enchantment, or null if not found
    • values

      public static Enchantment[] values()
      Gets an array of all the registered Enchantments
      Returns:
      Array of enchantments