Class UberUtils
java.lang.Object
me.sciguymjm.uberenchant.api.utils.UberUtils
Custom enchantment related utility class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEnchantment
(UberEnchantment enchant, org.bukkit.inventory.ItemStack item, int level) Adds the specified UberEnchantment to the item with specified level.static void
addEnchantmentLore
(org.bukkit.inventory.ItemStack item) Adds custom enchantment lore to the specified item if it contains any custom enchantments.
(An example would be "Sharpness V", if sharpness was custom)static String
displayName
(UberEnchantment enchantment, int level) Constructs the custom enchantment lore.
(Formatted as"<name> <level>"
ie "Sharpness V")static org.bukkit.inventory.ItemStack
extractEnchantment
(UberEnchantment enchantment, org.bukkit.inventory.ItemStack item) Extracts the specified UberEnchantment from the item and puts it as a stored enchantment on an enchanted book.static int
offset
(org.bukkit.inventory.ItemStack item) Gets the offset (if any) required for custom enchantment lore.static int
removeEnchantment
(UberEnchantment enchantment, org.bukkit.inventory.ItemStack item) Removes the specified UberEnchantment from the item, returning the level of the enchantment or 0.static void
removeEnchantmentLore
(org.bukkit.inventory.ItemStack item) Removes any custom enchantment lore on the specified itemstatic String
toRomanNumeral
(int number) Simple Integer to Roman numeral function.
-
Constructor Details
-
UberUtils
public UberUtils()
-
-
Method Details
-
addEnchantment
public static void addEnchantment(UberEnchantment enchant, org.bukkit.inventory.ItemStack item, int level) Adds the specified UberEnchantment to the item with specified level. Also adds the lore for displaying the enchantment on the item.- Parameters:
enchant
- - The enchantment to additem
- - The itemlevel
- - The level
-
removeEnchantment
public static int removeEnchantment(UberEnchantment enchantment, org.bukkit.inventory.ItemStack item) Removes the specified UberEnchantment from the item, returning the level of the enchantment or 0.- Parameters:
enchantment
- - The enchantment to removeitem
- - The item- Returns:
- The enchantment level or 0
-
extractEnchantment
public static org.bukkit.inventory.ItemStack extractEnchantment(UberEnchantment enchantment, org.bukkit.inventory.ItemStack item) Extracts the specified UberEnchantment from the item and puts it as a stored enchantment on an enchanted book.- Parameters:
enchantment
- - The enchantment to extractitem
- - The item- Returns:
- An enchanted book itemstack containing the extracted enchantment
-
addEnchantmentLore
public static void addEnchantmentLore(org.bukkit.inventory.ItemStack item) Adds custom enchantment lore to the specified item if it contains any custom enchantments.
(An example would be "Sharpness V", if sharpness was custom)- Parameters:
item
- - The item
-
removeEnchantmentLore
public static void removeEnchantmentLore(org.bukkit.inventory.ItemStack item) Removes any custom enchantment lore on the specified item- Parameters:
item
- - The item
-
displayName
Constructs the custom enchantment lore.
(Formatted as"<name> <level>"
ie "Sharpness V")- Parameters:
enchantment
- - The enchantmentlevel
- - ENchantment level- Returns:
- A string with the formatted display name
-
offset
public static int offset(org.bukkit.inventory.ItemStack item) Gets the offset (if any) required for custom enchantment lore.- Parameters:
item
- - The item- Returns:
- Amount of offset or 0 in case of no enchantments
-
toRomanNumeral
Simple Integer to Roman numeral function.- Parameters:
number
- - The number to convert- Returns:
- the converted number as a String or an empty String if number is less than 1
-