#753: RecipeIterator#hasNext will now accurately represent if the current iterator has a next item.

By: Martoph <sager1018@gmail.com>
This commit is contained in:
CraftBukkit/Spigot 2020-09-18 18:43:48 +10:00
parent 0ba5779850
commit 405ea090eb

View file

@ -19,13 +19,23 @@ public class RecipeIterator implements Iterator<Recipe> {
@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();