Class UberEnchantment

java.lang.Object
org.bukkit.enchantments.Enchantment
me.sciguymjm.uberenchant.api.UberEnchantment
All Implemented Interfaces:
org.bukkit.event.Listener, org.bukkit.Keyed
Direct Known Subclasses:
EffectEnchantment

public abstract class UberEnchantment extends org.bukkit.enchantments.Enchantment implements org.bukkit.event.Listener
The UberEnchantment class to be extended for adding 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
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new UberEnchantment using a unique key under UberEnchant.
    UberEnchantment(org.bukkit.NamespacedKey key)
    Constructs a new UberEnchantment using a unique custom NamespacedKey.
    UberEnchantment(org.bukkit.plugin.Plugin plugin, String key)
    Constructs a new UberEnchantment using plugin and string to create a unique NamespacedKey.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    containsEnchantment(org.bukkit.inventory.ItemStack item)
    Checks if the specified item contains this enchantment.
    static boolean
    containsEnchantment(org.bukkit.inventory.ItemStack item, UberEnchantment enchantment)
    Checks if the specified item contains the specified enchantment.
    abstract String
    Gets the display name of the enchantment.
    (Different from using getName() )
    getEnchantments(org.bukkit.inventory.ItemStack item)
    Gets a map containing all custom enchantments and their levels on this item.
    final int
    getLevel(org.bukkit.inventory.ItemStack item)
    Gets the level of this Enchantment on the specified item.
    static int
    getLevel(org.bukkit.inventory.ItemStack item, UberEnchantment enchantment)
    Gets the level of the specified enchantment on the specified item.
    final String
     
    abstract String
    Gets the permission for this enchantment.
    (Meant to be used within other plugins)
    Gets all registered custom enchantments.
    (Includes any plugins running on the server that implement UberEnchants API)
    Gets all custom enchantments registered to the specified plugin name.
    getRegisteredEnchantments(org.bukkit.plugin.Plugin plugin)
    Gets all custom enchantments regsitered to the specified plugin.
    getStoredEnchantments(org.bukkit.inventory.ItemStack item)
    Gets a map containing the stored enchantments in this item.
    (Usually reserved for an enchanted book)
    static boolean
    hasEnchantments(org.bukkit.inventory.ItemStack item)
    Checks if specified item has any custom enchantments.
    final boolean
    Checks if this enchantment is registered.
    static boolean
    Checks if the specified enchantment is registered.
    final boolean
    Registers this custom enchantment.
    static boolean
    Registers the specified custom enchantment.
    Gets an array of all custom enchantments, including unregistered ones

    Methods inherited from class org.bukkit.enchantments.Enchantment

    canEnchantItem, conflictsWith, equals, getByKey, getByName, getItemTarget, getKey, getMaxLevel, getStartLevel, hashCode, isAcceptingRegistrations, isCursed, isTreasure, registerEnchantment, stopAcceptingRegistrations, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UberEnchantment

      public UberEnchantment(org.bukkit.NamespacedKey key)
      Constructs a new UberEnchantment using a unique custom NamespacedKey.
      Parameters:
      key - - The NamespacedKey to be used
    • UberEnchantment

      public UberEnchantment(org.bukkit.plugin.Plugin plugin, String key)
      Constructs a new UberEnchantment using plugin and string to create a unique NamespacedKey.
      Parameters:
      plugin - - The plugin to register the key to
      key - - The key as a string to be used
    • UberEnchantment

      public UberEnchantment(String key)
      Constructs a new UberEnchantment using a unique key under UberEnchant.
      Parameters:
      key - - The key as a string to be used
  • Method Details

    • getName

      public final String getName()
      Specified by:
      getName in class org.bukkit.enchantments.Enchantment
    • getDisplayName

      public abstract String getDisplayName()
      Gets the display name of the enchantment.
      (Different from using getName() )
      Returns:
      The display name of this enchantment
    • getPermission

      public abstract String getPermission()
      Gets the permission for this enchantment.
      (Meant to be used within other plugins)
      Returns:
      The permission node
    • containsEnchantment

      public final boolean containsEnchantment(org.bukkit.inventory.ItemStack item)
      Checks if the specified item contains this enchantment.
      Parameters:
      item - - The item to check
      Returns:
      True if the item contains this enchantment
      See Also:
    • containsEnchantment

      public static boolean containsEnchantment(org.bukkit.inventory.ItemStack item, UberEnchantment enchantment)
      Checks if the specified item contains the specified enchantment.
      Parameters:
      item - - The item to check
      enchantment - - The Enchantment to check for
      Returns:
      True if the item contains the enchantment
      See Also:
    • getLevel

      public final int getLevel(org.bukkit.inventory.ItemStack item)
      Gets the level of this Enchantment on the specified item.
      Parameters:
      item - - The item
      Returns:
      The level or 0 if not found
      See Also:
    • getLevel

      public static int getLevel(org.bukkit.inventory.ItemStack item, UberEnchantment enchantment)
      Gets the level of the specified enchantment on the specified item.
      Parameters:
      item - - The item
      enchantment - - The enchantment
      Returns:
      The level or 0 if not found
      See Also:
    • hasEnchantments

      public static boolean hasEnchantments(org.bukkit.inventory.ItemStack item)
      Checks if specified item has any custom enchantments.
      Parameters:
      item - - The item to check
      Returns:
      True if any custom enchantments were found
    • getEnchantments

      public static Map<UberEnchantment,Integer> getEnchantments(org.bukkit.inventory.ItemStack item)
      Gets a map containing all custom enchantments and their levels on this item.
      Parameters:
      item - - The item
      Returns:
      Map of custom enchantments (Can be empty)
    • getStoredEnchantments

      public static Map<UberEnchantment,Integer> getStoredEnchantments(org.bukkit.inventory.ItemStack item)
      Gets a map containing the stored enchantments in this item.
      (Usually reserved for an enchanted book)
      Parameters:
      item - - The item
      Returns:
      Map of stored custom enchantments (Can be empty)
    • getRegisteredEnchantments

      public static List<UberEnchantment> getRegisteredEnchantments()
      Gets all registered custom enchantments.
      (Includes any plugins running on the server that implement UberEnchants API)
      Returns:
      List of custom enchantments
      See Also:
    • getRegisteredEnchantments

      public static List<UberEnchantment> getRegisteredEnchantments(org.bukkit.plugin.Plugin plugin)
      Gets all custom enchantments regsitered to the specified plugin.
      Parameters:
      plugin - - The plugin
      Returns:
      List of custom enchantments
      See Also:
    • getRegisteredEnchantments

      public static List<UberEnchantment> getRegisteredEnchantments(String plugin)
      Gets all custom enchantments registered to the specified plugin name.
      Parameters:
      plugin - - The plugin name
      Returns:
      List of custom enchantments
      See Also:
    • register

      public final boolean register()
      Registers this custom enchantment.
      Returns:
      True if successfully registered
      See Also:
    • register

      public static boolean register(UberEnchantment enchantment)
      Registers the specified custom enchantment.
      Parameters:
      enchantment - - The enchantment to register
      Returns:
      True if successfully registered
      See Also:
    • isRegistered

      public final boolean isRegistered()
      Checks if this enchantment is registered.
      Returns:
      True if already registered
      See Also:
    • isRegistered

      public static boolean isRegistered(UberEnchantment enchantment)
      Checks if the specified enchantment is registered.
      Parameters:
      enchantment - - The enchantment to check
      Returns:
      True if already registered
      See Also:
    • values

      public static UberEnchantment[] values()
      Gets an array of all custom enchantments, including unregistered ones
      Returns:
      An array of every custom enchantment