Package me.hsgamer.hscore.bukkit.utils
Class ItemUtils
java.lang.Object
me.hsgamer.hscore.bukkit.utils.ItemUtils
Methods on items
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The session of the item check. -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemUtils.ItemCheckSession
createItemCheckSession
(org.bukkit.inventory.Inventory inventory, Predicate<org.bukkit.inventory.ItemStack> predicate, int maxAmount) Create a newItemUtils.ItemCheckSession
that check the inventory for the items that match the predicatestatic Predicate<org.bukkit.inventory.ItemStack>
getItemPredicate
(org.bukkit.inventory.ItemStack itemStack) Get the predicate of the item.static List<org.bukkit.inventory.ItemStack>
getMatchedItemsInInventory
(org.bukkit.inventory.Inventory inventory, Predicate<org.bukkit.inventory.ItemStack> predicate, int maxAmount) Get the matched items in the inventorystatic void
giveItem
(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack... itemStack) Give the item to the playerstatic boolean
isItemFullOnInventory
(org.bukkit.inventory.Inventory inventory, Collection<org.bukkit.inventory.ItemStack> items) Check if the items cannot be added to the inventorystatic boolean
isItemFullOnInventory
(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack item) Check if the item cannot be added to the inventorystatic void
removeItemInInventory
(org.bukkit.inventory.Inventory inventory, Collection<org.bukkit.inventory.ItemStack> items) Remove the items in the inventorystatic void
removeItemInInventory
(org.bukkit.inventory.Inventory inventory, Predicate<org.bukkit.inventory.ItemStack> predicate, int amount) Remove the matched items in the inventory
-
Method Details
-
giveItem
public static void giveItem(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack... itemStack) Give the item to the player- Parameters:
player
- the playeritemStack
- the item
-
getMatchedItemsInInventory
public static List<org.bukkit.inventory.ItemStack> getMatchedItemsInInventory(org.bukkit.inventory.Inventory inventory, Predicate<org.bukkit.inventory.ItemStack> predicate, int maxAmount) Get the matched items in the inventory- Parameters:
inventory
- the inventorypredicate
- the item predicatemaxAmount
- the max amount to get- Returns:
- the matched items
- See Also:
-
removeItemInInventory
public static void removeItemInInventory(org.bukkit.inventory.Inventory inventory, Collection<org.bukkit.inventory.ItemStack> items) Remove the items in the inventory- Parameters:
inventory
- the inventoryitems
- the items
-
removeItemInInventory
public static void removeItemInInventory(org.bukkit.inventory.Inventory inventory, Predicate<org.bukkit.inventory.ItemStack> predicate, int amount) Remove the matched items in the inventory- Parameters:
inventory
- the inventorypredicate
- the item predicateamount
- the amount- See Also:
-
getItemPredicate
public static Predicate<org.bukkit.inventory.ItemStack> getItemPredicate(org.bukkit.inventory.ItemStack itemStack) Get the predicate of the item. This will check the item similarity- Parameters:
itemStack
- the item- Returns:
- the predicate
- See Also:
-
ItemStack.isSimilar(ItemStack)
-
isItemFullOnInventory
public static boolean isItemFullOnInventory(org.bukkit.inventory.Inventory inventory, Collection<org.bukkit.inventory.ItemStack> items) Check if the items cannot be added to the inventory- Parameters:
inventory
- the inventoryitems
- the items- Returns:
- true if the items cannot be added to the inventory
-
isItemFullOnInventory
public static boolean isItemFullOnInventory(org.bukkit.inventory.Inventory inventory, org.bukkit.inventory.ItemStack item) Check if the item cannot be added to the inventory- Parameters:
inventory
- the inventoryitem
- the item- Returns:
- true if the item cannot be added to the inventory
-
createItemCheckSession
public static ItemUtils.ItemCheckSession createItemCheckSession(org.bukkit.inventory.Inventory inventory, Predicate<org.bukkit.inventory.ItemStack> predicate, int maxAmount) Create a newItemUtils.ItemCheckSession
that check the inventory for the items that match the predicate- Parameters:
inventory
- the inventorypredicate
- the item predicatemaxAmount
- the max amount to check- Returns:
- the
ItemUtils.ItemCheckSession
- See Also:
-