From da9bb3ea92c406be1ef4d35aecf092ec917fd6ca Mon Sep 17 00:00:00 2001 From: Martoph Date: Fri, 18 Sep 2020 18:43:48 +1000 Subject: [PATCH] #753: RecipeIterator#hasNext will now accurately represent if the current iterator has a next item. --- .../bukkit/craftbukkit/inventory/RecipeIterator.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java index 1223bfc7f5..28f77a341e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/RecipeIterator.java @@ -19,13 +19,23 @@ public class RecipeIterator implements Iterator { @Override public boolean hasNext() { - return (current != null && current.hasNext()) || recipes.hasNext(); + if (current != null && current.hasNext()) { + return true; + } + + if (recipes.hasNext()) { + current = recipes.next().getValue().values().iterator(); + return hasNext(); + } + + return false; } @Override public Recipe next() { if (current == null || !current.hasNext()) { current = recipes.next().getValue().values().iterator(); + return next(); } return current.next().toBukkitRecipe();