Package me.sciguymjm.uberenchant.api
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
ConstructorDescriptionUberEnchantment
(String key) 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 TypeMethodDescriptionfinal 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 usinggetName()
)static Map<UberEnchantment,
Integer> 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
getName()
abstract String
Gets the permission for this enchantment.
(Meant to be used within other plugins)static List<UberEnchantment>
Gets all registered custom enchantments.
(Includes any plugins running on the server that implement UberEnchants API)static List<UberEnchantment>
getRegisteredEnchantments
(String plugin) Gets all custom enchantments registered to the specified plugin name.static List<UberEnchantment>
getRegisteredEnchantments
(org.bukkit.plugin.Plugin plugin) Gets all custom enchantments regsitered to the specified plugin.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)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
isRegistered
(UberEnchantment enchantment) Checks if the specified enchantment is registered.final boolean
register()
Registers this custom enchantment.static boolean
register
(UberEnchantment enchantment) Registers the specified custom enchantment.static UberEnchantment[]
values()
Gets an array of all custom enchantments, including unregistered onesMethods inherited from class org.bukkit.enchantments.Enchantment
canEnchantItem, conflictsWith, equals, getByKey, getByName, getItemTarget, getKey, getMaxLevel, getStartLevel, hashCode, isAcceptingRegistrations, isCursed, isTreasure, registerEnchantment, stopAcceptingRegistrations, toString
-
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
Constructs a new UberEnchantment using plugin and string to create a unique NamespacedKey.- Parameters:
plugin
- - The plugin to register the key tokey
- - The key as a string to be used
-
UberEnchantment
Constructs a new UberEnchantment using a unique key under UberEnchant.- Parameters:
key
- - The key as a string to be used
-
-
Method Details
-
getName
- Specified by:
getName
in classorg.bukkit.enchantments.Enchantment
-
getDisplayName
Gets the display name of the enchantment.
(Different from usinggetName()
)- Returns:
- The display name of this enchantment
-
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 checkenchantment
- - 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
Gets the level of the specified enchantment on the specified item.- Parameters:
item
- - The itemenchantment
- - 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
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
Gets all registered custom enchantments.
(Includes any plugins running on the server that implement UberEnchants API)- Returns:
- List of custom enchantments
- See Also:
-
getRegisteredEnchantments
Gets all custom enchantments regsitered to the specified plugin.- Parameters:
plugin
- - The plugin- Returns:
- List of custom enchantments
- See Also:
-
getRegisteredEnchantments
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
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
Checks if the specified enchantment is registered.- Parameters:
enchantment
- - The enchantment to check- Returns:
- True if already registered
- See Also:
-
values
Gets an array of all custom enchantments, including unregistered ones- Returns:
- An array of every custom enchantment
-