You could try doing something like this if you just want to get a single potion:
Optional<Item> staminaPotion = Arrays.stream(getBank().getItems())
.filter(item -> item != null && item.getName().startsWith("Stamina potion"))
.min(Comparator.comparing(Item::getName));
This snippet will construct a Stream from the array of all items in the bank, filter it so that only the items which are not null and has a name beginning with "Stamina potion" remain, and then find the min of those using a Comparator to compare the Item names, this should return Stamina potion (1) first etc.
Note: it returns an Optional<Item>, the Optional class can be found here
You use it like so:
if (staminaPotion.isPresent()) {
Item pot = staminaPotion.get();
}
Or to get the List of all stamina potions in the bank, sorted by dosage:
List<Item> staminaPotion = Arrays.stream(getBank().getItems())
.filter(item -> item != null && item.getName().startsWith("Stamina potion"))
.sorted(Comparator.comparing(Item::getName))
.collect(Collectors.toList());
This snippet is similar to the above, but instead of returning the min, it instead sorts the Stream using the same Comparator, and then collects the Items into a List