Exemplo n.º 1
0
 public void removeItem(byte slot, short quantity, boolean allowZero) {
   IItem item = inventory.get(slot);
   if (item == null) { // TODO is it ok not to throw an exception here?
     return;
   }
   item.setQuantity((short) (item.getQuantity() - quantity));
   if (item.getQuantity() < 0) {
     item.setQuantity((short) 0);
   }
   if (item.getQuantity() == 0 && !allowZero) {
     removeSlot(slot);
   }
 }
Exemplo n.º 2
0
 public int countById(int itemId) {
   int possesed = 0;
   for (IItem item : inventory.values()) {
     if (item.getItemId() == itemId) {
       possesed += item.getQuantity();
     }
   }
   return possesed;
 }