diff --git a/iutils/src/main/java/net/runelite/client/plugins/iutils/scripts/UtilsScript.java b/iutils/src/main/java/net/runelite/client/plugins/iutils/scripts/UtilsScript.java index 12668006..daa3596c 100644 --- a/iutils/src/main/java/net/runelite/client/plugins/iutils/scripts/UtilsScript.java +++ b/iutils/src/main/java/net/runelite/client/plugins/iutils/scripts/UtilsScript.java @@ -109,7 +109,9 @@ public abstract class UtilsScript extends Plugin { } protected void obtain(List items) { - if (items.isEmpty() || hasItems(items)) { + if (items.isEmpty() || + + Items(items)) { return; } obtain(items.toArray(ItemQuantity[]::new)); @@ -191,6 +193,30 @@ public abstract class UtilsScript extends Plugin { return bankItem == null ? 0 : bankItem.quantity(); } + protected boolean equipmentHasItemsID(Integer items) { + return game.equipment().withId(items).findFirst().isPresent(); + } + protected boolean equipmentHasItemsID(Collection items) { + return game.equipment().withId(items).findFirst().isPresent(); + } + + protected boolean inventoryHasItemsName(String items) { + return game.inventory().withNamePart(items).findFirst().isPresent(); + } + protected boolean inventoryHasItemsName(Collection items) { + for (String item : items) { + return game.inventory().withNamePart(item).findFirst().isPresent(); + } + return false; + } + + protected boolean inventoryHasItems(Integer items) { + return game.inventory().withId(items).findFirst().isPresent(); + } + protected boolean inventoryHasItems(Collection items) { + return game.inventory().withId(items).findFirst().isPresent(); + } + protected boolean inventoryHasItems(ItemQuantity... items) { return inventoryHasItems(false, items); } diff --git a/iutils/src/main/java/net/runelite/client/plugins/iutils/ui/EquipmentItemStream.java b/iutils/src/main/java/net/runelite/client/plugins/iutils/ui/EquipmentItemStream.java index 5ee0f7ab..665828d3 100644 --- a/iutils/src/main/java/net/runelite/client/plugins/iutils/ui/EquipmentItemStream.java +++ b/iutils/src/main/java/net/runelite/client/plugins/iutils/ui/EquipmentItemStream.java @@ -18,14 +18,35 @@ public class EquipmentItemStream extends RandomizedStreamAdapter Arrays.stream(ids).anyMatch(id -> o.id() == id)); } + /** + * Returns a stream consisting of the elements of this stream with + * any of the given {@link InventoryItem#id()}s + */ + public EquipmentItemStream withId(Collection ids) { + return filter(o -> ids.stream().anyMatch(id -> o.id() == id)); + } + /** + * Returns a stream consisting of the elements of this stream that don't match + * any of the given {@link InventoryItem#id()}s + */ + public EquipmentItemStream withoutId(Collection ids) { + return filter(o -> ids.stream().noneMatch(id -> o.id() == id)); + } + /** + * Returns a stream consisting of the elements of this stream that don't match + * any of the given {@link InventoryItem#id()}s + */ + public EquipmentItemStream withoutId(int... ids) { + return filter(o -> Arrays.stream(ids).noneMatch(id -> o.id() == id)); + } /** * Returns a stream consisting of the elements of this stream with * a minimum {@link EquipmentItem#quantity()} @@ -49,6 +70,13 @@ public class EquipmentItemStream extends RandomizedStreamAdapter Arrays.stream(names).anyMatch(name -> o.name().toLowerCase().contains(name.toLowerCase()))); } + /** + * Returns a stream consisting of the elements of this stream that don't match + * any of the given {@link InventoryItem#name()}s + */ + public EquipmentItemStream withoutNamePart(String... names) { + return filter(o -> Arrays.stream(names).noneMatch(name -> o.name().toLowerCase().contains(name.toLowerCase()))); + } /** * Returns a stream consisting of the elements of this stream with