commit
2c9943d629
|
@ -109,7 +109,9 @@ public abstract class UtilsScript extends Plugin {
|
|||
}
|
||||
|
||||
protected void obtain(List<ItemQuantity> 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<Integer> items) {
|
||||
return game.equipment().withId(items).findFirst().isPresent();
|
||||
}
|
||||
|
||||
protected boolean inventoryHasItemsName(String items) {
|
||||
return game.inventory().withNamePart(items).findFirst().isPresent();
|
||||
}
|
||||
protected boolean inventoryHasItemsName(Collection<String> 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<Integer> items) {
|
||||
return game.inventory().withId(items).findFirst().isPresent();
|
||||
}
|
||||
|
||||
protected boolean inventoryHasItems(ItemQuantity... items) {
|
||||
return inventoryHasItems(false, items);
|
||||
}
|
||||
|
|
|
@ -18,14 +18,35 @@ public class EquipmentItemStream extends RandomizedStreamAdapter<EquipmentItem,
|
|||
return new EquipmentItemStream(stream);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Returns a stream consisting of the elements of this stream with
|
||||
* any of the given {@link EquipmentItem#id()}s
|
||||
*/
|
||||
public EquipmentItemStream withId(int... ids) {
|
||||
return filter(o -> 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<Integer> 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<Integer> 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<EquipmentItem,
|
|||
public EquipmentItemStream withNamePart(String... names) {
|
||||
return filter(o -> 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
|
||||
|
|
Loading…
Reference in New Issue