Don't map item amount in Inventory#add(int, int).

This commit is contained in:
Ryley Kimmel
2015-02-25 15:30:46 -05:00
parent 87ff14c4d7
commit edd7b483af
+2 -2
View File
@@ -117,8 +117,8 @@ public final class Inventory {
* @return The amount that remains.
*/
public int add(int id, int amount) {
Optional<Item> optionalItem = add(new Item(id, amount));
return optionalItem.map(item -> optionalItem.isPresent() ? item.getAmount() : 0).get();
Optional<Item> item = add(new Item(id, amount));
return item.isPresent() ? item.get().getAmount() : 0;
}
/**