public class ItemUtils
extends java.lang.Object
EquipmentUtils
,
FoodUtils
,
PetEggUtils
Constructor and Description |
---|
ItemUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
countSpecificStackableItems(org.bukkit.inventory.Inventory inventory,
org.bukkit.inventory.ItemStack itemStack)
Counts the total amount of the given item stack inside an inventory.
|
static boolean |
doesLoreContain(org.bukkit.inventory.ItemStack itemStack,
java.lang.String content)
Checks if the lore of the item stack contains the given string.
|
static boolean |
fitsInInventory(org.bukkit.inventory.Inventory inventory,
org.bukkit.inventory.ItemStack itemStack)
Checks if enough space is left in an inventory, to fit in the given item stack.
|
private static int |
getAmountOfStacks(int maxStackSize,
int itemAmount)
Counts how many stacks are needed to fit the given amount of items.
|
static int |
getArrowCount(org.bukkit.inventory.ItemStack itemStack)
Gets the amount of arrows from an item stack, based on lore.
|
static java.lang.String |
getDisplayName(org.bukkit.inventory.ItemStack itemStack)
Gets the display name of the given item stack.
|
static java.lang.String |
getInstanceMapType(org.bukkit.inventory.ItemStack itemStack)
Gets the map type of an item stack, based on lore.
|
static int |
getIntegerBetweenFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String before,
java.lang.String after)
Finds an int between two strings somewhere inside an item's lore.
|
static int |
getIntegerFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String content,
int index)
Gets an integer from an item stack's lore, based on line content and word index.
|
static int |
getIntegerSumBetweenFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String before,
java.lang.String after)
Finds the sum of all integers between all occurances of two strings somewhere inside an item's lore.
|
static long |
getLongFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String content,
int index)
Gets a long from an item stack's lore, based on line content and word index.
|
static int |
getSellValue(org.bukkit.inventory.ItemStack itemStack)
Gets the sell value of an item stack, based on lore.
|
static java.lang.String |
getStringBetweenFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String before,
java.lang.String after)
Finds a string between two other strings somewhere inside an item's lore.
|
static java.lang.String |
getStringFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String content,
int index)
Gets a string from an item stack's lore, based on line content and word index.
|
static boolean |
hasColoredName(org.bukkit.inventory.ItemStack itemStack,
org.bukkit.ChatColor chatColor)
Checks if the given color is contained in an item stack's display name.
|
static boolean |
hasDisplayName(org.bukkit.inventory.ItemStack itemStack)
Checks if the given item stack has a display name.
|
static boolean |
hasEqualLore(org.bukkit.inventory.ItemStack itemStackA,
org.bukkit.inventory.ItemStack itemStackB)
Checks if the given item stacks have the same lore.
|
static boolean |
hasLore(org.bukkit.inventory.ItemStack itemStack)
Checks if the given item has a lore.
|
static boolean |
isAmmoItem(org.bukkit.inventory.ItemStack itemStack)
Checks if an item stack is an ammo item, based on lore.
|
static boolean |
isBanner(org.bukkit.inventory.ItemStack itemStack)
Checks if an item stack possesses a banner meta.
|
static boolean |
isBoughtItem(org.bukkit.inventory.ItemStack itemStack)
Checks if an item stack is a bought item, based on lore.
|
static boolean |
isInstanceMap(org.bukkit.inventory.ItemStack itemStack)
Checks if the item stack is an instance map, based on lore.
|
static boolean |
isMaterial(org.bukkit.inventory.ItemStack itemStack,
org.bukkit.Material material)
Checks if the item stack is not null and made out of a given material.
|
static boolean |
isMaterialItem(org.bukkit.inventory.ItemStack itemStack)
Checks if an item stack is a material, based on lore.
|
static boolean |
isNotAir(org.bukkit.inventory.ItemStack itemStack)
Checks if an item stack is neither null or air.
|
static boolean |
isQuestItem(org.bukkit.inventory.ItemStack itemStack)
Checks if an item stack is a quest item, based on lore.
|
static boolean |
isSpecificItem(org.bukkit.inventory.ItemStack itemStack,
java.lang.String itemName)
Checks if an item stack is a specific item, based on display name.
|
static boolean |
replaceStringFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String content,
int index,
java.lang.String replacement)
Replaces a substring with given word index in all occurances of a string inside an item's lore.
|
static boolean |
replaceStringFromLore(org.bukkit.inventory.ItemStack itemStack,
java.lang.String content,
java.lang.String replacement)
Replaces all occurances of a line inside an item stack's lore.
|
public static boolean isNotAir(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static boolean isMaterial(org.bukkit.inventory.ItemStack itemStack, org.bukkit.Material material)
itemStack
- The item stack to check.material
- The material to check for.public static boolean fitsInInventory(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack itemStack)
inventory
- The inventory to iterate through.itemStack
- The item stack to check for.countSpecificStackableItems(Inventory, ItemStack)
,
getAmountOfStacks(int, int)
private static int getAmountOfStacks(int maxStackSize, int itemAmount)
maxStackSize
- The maximum stack size of that item.itemAmount
- The amount of items.public static int countSpecificStackableItems(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack itemStack)
inventory
- The inventory to iterate through.itemStack
- The item stack to check for.isSpecificItem(ItemStack, String)
public static boolean isSpecificItem(org.bukkit.inventory.ItemStack itemStack, java.lang.String itemName)
itemStack
- The item stack to check.itemName
- The item name to check for.public static boolean isBanner(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static boolean isMaterialItem(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static boolean isQuestItem(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static boolean isAmmoItem(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.getArrowCount(ItemStack)
public static boolean isBoughtItem(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.getSellValue(ItemStack)
public static int getArrowCount(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.isAmmoItem(ItemStack)
public static int getSellValue(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.isBoughtItem(ItemStack)
public static boolean isInstanceMap(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.isInstanceMap(ItemStack)
public static java.lang.String getInstanceMapType(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.isInstanceMap(ItemStack)
public static boolean hasColoredName(org.bukkit.inventory.ItemStack itemStack, org.bukkit.ChatColor chatColor)
itemStack
- The item stack to check.chatColor
- The color to check for.public static boolean hasDisplayName(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static java.lang.String getDisplayName(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static boolean hasLore(org.bukkit.inventory.ItemStack itemStack)
itemStack
- The item stack to check.public static boolean hasEqualLore(org.bukkit.inventory.ItemStack itemStackA, org.bukkit.inventory.ItemStack itemStackB)
itemStackA
- The first item stack to check.itemStackB
- The second item stack to check.public static boolean doesLoreContain(org.bukkit.inventory.ItemStack itemStack, java.lang.String content)
itemStack
- The item stack to check.content
- The string to check for.public static java.lang.String getStringFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String content, int index)
itemStack
- The item stack to check.content
- The string to identify the line with.index
- The word index inside the found line.public static java.lang.String getStringBetweenFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String before, java.lang.String after)
itemStack
- The item stack to check.before
- The string before the wanted string.after
- The string after the wanted string.public static int getIntegerFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String content, int index)
itemStack
- The item stack to check.content
- The string to identify the line with.index
- The word index inside the found line.public static int getIntegerBetweenFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String before, java.lang.String after)
itemStack
- The item stack to check.before
- The string before the wanted int.after
- The string after the wanted int.public static int getIntegerSumBetweenFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String before, java.lang.String after)
itemStack
- The item stack to check.before
- The string before the wanted int.after
- The string after the wanted int.public static long getLongFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String content, int index)
itemStack
- The item stack to check.content
- The string to identify the line with.index
- The word index inside the found line.public static boolean replaceStringFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String content, java.lang.String replacement)
itemStack
- The item stack to edit.content
- The string to identify the line with.replacement
- The replacement of the content.public static boolean replaceStringFromLore(org.bukkit.inventory.ItemStack itemStack, java.lang.String content, int index, java.lang.String replacement)
itemStack
- The item stack to edit.content
- The string to identify the line with.index
- The word index of the substring to replace inside the found line.replacement
- The replacement of the content.