Enum Class EnchantmentTag

java.lang.Object
java.lang.Enum<EnchantmentTag>
com.saicone.rtag.util.EnchantmentTag
All Implemented Interfaces:
Serializable, Comparable<EnchantmentTag>, Constable

public enum EnchantmentTag extends Enum<EnchantmentTag>
Minecraft enchantment tags with associated ID.
Take in count Mojang discontinued IDs since MC 1.14, any ID for new enchantments is not official.
  • Enum Constant Details

  • Field Details

    • VALUES

      public static final EnchantmentTag[] VALUES
      Cached values of values().
    • LEGACY_VALUES

      public static final EnchantmentTag[] LEGACY_VALUES
      Cached values of values() including only pre 1.13 enchantments.
    • SERVER_VALUES

      public static final EnchantmentTag[] SERVER_VALUES
      Cached values of values() including only server version compatible enchantments.
    • TAG_KEY

      public static final String TAG_KEY
      Current key where enchantments are inside items tag.
    • STORED_KEY

      public static final String STORED_KEY
      Current key where stored enchantments are inside items tag.
      See Also:
  • Method Details

    • values

      public static EnchantmentTag[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EnchantmentTag valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getMinimumVersion

      @NotNull public @NotNull com.saicone.rtag.util.MC getMinimumVersion()
      Get the minimum compatible version for this enchantment.
      Returns:
    • getId

      public short getId()
      Get enchant numeric ID.
      Returns:
      A number representing the enchantment.
    • getAliases

      public String[] getAliases()
      Get current enchant aliases.
      Returns:
      A string array with enchant aliases.
    • getEnchantment

      public Enchantment getEnchantment()
      Get current enchant as Enchantment.
      Returns:
      A Bukkit enchantment if exist on the current version, null otherwise.
    • getKey

      public Object getKey()
      Get current enchant key depending on current Bukkit version.
      Returns:
      Short id for legacy versions, namespaced key otherwise.
    • compare

      public boolean compare(Object name)
      Check if the current EnchantmentTag correspond to name object.
      Parameters:
      name - Enchantment name, alias or short id.
      Returns:
      true if the EnchantmentTag is assigned to name object.
    • compareKey

      public boolean compareKey(Object key)
      Check if the current EnchantmentTag correspond to key object.
      Parameters:
      key - Namespaced key or short id.
      Returns:
      true if the EnchantmentTag is assigned to key object.
    • parseName

      public static Object parseName(Object name)
      Parse the current object name into the most convenient format for EnchantmentTag.
      Parameters:
      name - Object representing the EnchantmentTag comparison.
      Returns:
      Enchantment name, alias or short id.
    • getEnchantmentKey

      public static String getEnchantmentKey(ItemStack item)
      Get the current key where enchantments are stored in the item tag depending on item meta or server version.
      Parameters:
      item - Item to check enchantment key.
      Returns:
      A String key.
    • of

      public static EnchantmentTag of(Object name)
      Get the EnchantmentTag of provided name, short id or Enchantment.
      Parameters:
      name - Enchantment name, alias or short id.
      Returns:
      The EnchantmentTag assigned to key object, null if not exist.
    • getVersion

      @Deprecated(since="1.5.14", forRemoval=true) public int getVersion()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get added version for this enchant.
      Returns:
      A server version number.