September 4, 20178 yr public static String[] axes = new String[] { "Iron axe", "Bronze axe", "Steel axe", "Mithril axe", "Adamant axe" }; I'm using the above, my question is when i use this to verify if my inventory contains the above items, why does it continue to execute when it only contains one of the items from the array I want it to execute when it contains all of those items not just one Edited September 4, 20178 yr by aftabdear
September 4, 20178 yr Because Inventory.contains only checks if it contains any of the given items, not all of the given items. You could try: Arrays.stream(axes).allMatch(i -> getInventory().contains(i)) This would make sure it contains all the items in your inventory, instead of just 1.
September 4, 20178 yr getInventory().contains(item -> item.getName().contains("axe")); My bad, didn't read it correctly. Lemon posted the correct answer. Edited September 4, 20178 yr by The Undefeated
Create an account or sign in to comment