mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-03 08:39:11 +00:00
Add extra utility methods to Inventory and utils plugin.
This commit is contained in:
@@ -415,6 +415,24 @@ public final class Inventory {
|
||||
return remove(id, 1) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes one item with each of the specified ids.
|
||||
* <p>
|
||||
* This method will attempt to remove one of each item, and will continue even if a previous item could not be
|
||||
* removed.
|
||||
*
|
||||
* @param ids The ids of the item to remove.
|
||||
* @return {@code true} if one of each item could be removed, otherwise {@code false}.
|
||||
*/
|
||||
public boolean remove(int... ids) {
|
||||
boolean successful = true;
|
||||
for (int id : ids) {
|
||||
successful &= remove(id);
|
||||
}
|
||||
|
||||
return successful;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes {@code amount} of the item with the specified {@code id}. If the item is stackable, it will remove it
|
||||
* from the stack. If not, it'll remove {@code amount} items.
|
||||
@@ -505,7 +523,7 @@ public final class Inventory {
|
||||
int removed = Math.min(amount, itemAmount);
|
||||
int remainder = itemAmount - removed;
|
||||
|
||||
set(slot, remainder > 0 ? new Item(item.getId(), remainder) : null);
|
||||
set(slot, (remainder > 0) ? new Item(item.getId(), remainder) : null);
|
||||
return removed;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user