mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 07:48:53 +01:00
#753: RecipeIterator#hasNext will now accurately represent if the current iterator has a next item.
This commit is contained in:
parent
890130b460
commit
da9bb3ea92
1 changed files with 11 additions and 1 deletions
|
@ -19,13 +19,23 @@ public class RecipeIterator implements Iterator<Recipe> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
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
|
@Override
|
||||||
public Recipe next() {
|
public Recipe next() {
|
||||||
if (current == null || !current.hasNext()) {
|
if (current == null || !current.hasNext()) {
|
||||||
current = recipes.next().getValue().values().iterator();
|
current = recipes.next().getValue().values().iterator();
|
||||||
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
return current.next().toBukkitRecipe();
|
return current.next().toBukkitRecipe();
|
||||||
|
|
Loading…
Reference in a new issue