iutils: fix for obtain() getting stuck

This commit is contained in:
illumineawake 2021-08-20 14:45:34 +10:00
parent 616ef2e336
commit 33c20069ca
4 changed files with 8 additions and 6 deletions

View File

@ -23,7 +23,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
version = "4.4.6"
version = "4.4.7"
project.extra["PluginName"] = "iUtils"
project.extra["PluginDescription"] = "Illumine - Utils required for plugins to function with added automation"

View File

@ -116,19 +116,21 @@ public abstract class UtilsScript extends Plugin {
}
protected void obtain(List<ItemQuantity> items, boolean keepInventoryItems) {
if (items.isEmpty() || hasItems(items)) {
List<ItemQuantity> test = new ArrayList<>(items);
if (test.isEmpty() || hasItems(test)) {
return;
}
if (keepInventoryItems) {
items.addAll(inventoryList());
log.info("Keeping items: {}", items.toString());
test.addAll(inventoryList());
log.info("Keeping items: {}", test.toString());
}
obtain(items.toArray(ItemQuantity[]::new));
obtain(test.toArray(ItemQuantity[]::new));
}
protected List<ItemQuantity> inventoryList() {
return game.inventory().all().stream()
.map(i -> new ItemQuantity(i.id(), i.quantity()))
.collect(Collectors.toList());

File diff suppressed because one or more lines are too long