Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Get first page with matching item inside.
- *
- * @param item item you want to check.
- * @return inventory some contains at lest 1 item.
- */
- public Inventory getFirstPageWithItems(ItemStack item) {
- ArrayList<Inventory> inventoriesList = getInventory(this.location);
- if (inventoriesList.size() > 1) {
- for (Inventory inventory : inventoriesList)
- for (ItemStack itemStack : inventory.getContents())
- if (itemStack != null && itemStack.getType() != Material.AIR && item != null && (itemStack.isSimilar(item) || itemStack.getType() == item.getType()) )
- return inventory;
- } else {
- return inventoriesList.get(0);
- }
- return null;
- }
- /**
- * Get amount of one item type
- *
- * @param itemStack item you want to check amount.
- * @return amount of this itemStack.
- */
- public int getAmountOfOneItem(ItemStack itemStack){
- int amount=0;
- ArrayList<Inventory> inventoriesList = getInventory(this.location);
- for (Inventory inventory : inventoriesList)
- amount = ItemUtily.countItemStacks(itemStack, inventory);
- return amount;
- }
Add Comment
Please, Sign In to add comment