コード例 #1
0
 /**
  * Gets the count of all the inventory items matching with any of the provided ids.
  *
  * @param includeStacks <tt>true</tt> to count the stack sizes of each item; otherwise
  *     <tt>false</tt>
  * @param itemIds the item ids to include
  * @return the count
  */
 public static int getCount(boolean includeStacks, int... itemIds) {
   int count = 0;
   Item[] items = getItems(itemIds);
   for (Item item : items) {
     if (item == null) continue;
     int itemId = item.getId();
     if (itemId != -1) {
       count += includeStacks ? item.getStackSize() : 1;
     }
   }
   return count;
 }
コード例 #2
0
 /**
  * Gets the count of all the inventory items excluding any of the provided ids.
  *
  * @param includeStacks <tt>true</tt> to count the stack sizes of each item; otherwise
  *     <tt>false</tt>
  * @param ids the ids to exclude
  * @return the count
  */
 public static int getCountExcept(boolean includeStacks, int... ids) {
   int count = 0;
   Item[] items = getItems();
   outer:
   for (Item item : items) {
     if (item == null) continue;
     int itemId = item.getId();
     for (int id : ids) {
       if (itemId == id) continue outer;
     }
     count += includeStacks ? item.getStackSize() : 1;
   }
   return count;
 }