broken-arrow

Untitled

Jan 23rd, 2022 (edited)
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1.     /**
  2.      * Get first page with matching item inside.
  3.      *
  4.      * @param item item you want to check.
  5.      * @return inventory some contains at lest 1 item.
  6.      */
  7.  
  8.     public Inventory getFirstPageWithItems(ItemStack item) {
  9.         ArrayList<Inventory> inventoriesList = getInventory(this.location);
  10.         if (inventoriesList.size() > 1) {
  11.             for (Inventory inventory : inventoriesList)
  12.                 for (ItemStack itemStack : inventory.getContents())
  13.                     if (itemStack != null && itemStack.getType() != Material.AIR && item != null && (itemStack.isSimilar(item) || itemStack.getType() == item.getType())   )
  14.                         return inventory;
  15.         } else {
  16.             return inventoriesList.get(0);
  17.         }
  18.         return null;
  19.     }
  20.  
  21.     /**
  22.      * Get amount of one item type
  23.      *
  24.      * @param itemStack item you want to check amount.
  25.      * @return amount of this itemStack.
  26.      */
  27.     public int getAmountOfOneItem(ItemStack itemStack){
  28.         int amount=0;
  29.         ArrayList<Inventory> inventoriesList = getInventory(this.location);
  30.         for (Inventory inventory : inventoriesList)
  31.             amount = ItemUtily.countItemStacks(itemStack, inventory);
  32.         return amount;
  33.     }
Add Comment
Please, Sign In to add comment