Skip to content

Commit 6c29fd5

Browse files
committed
chore/fix: update iterator
1 parent 7acc488 commit 6c29fd5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Core/src/main/java/com/plotsquared/core/util/query/PlotProvider.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ interface PlotProvider {
3535
Stream<Plot> streamPlots();
3636

3737
default Stream<Plot> streamPlotsInPlotAreas(PlotArea[] areas) {
38+
if (areas == null || areas.length == 0) {
39+
return Stream.of();
40+
}
3841
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new Iterator<>() {
3942
private int areaIndex = -1;
4043
private Iterator<Plot> currentAreaPlots;
4144
@Override
4245
public boolean hasNext() {
43-
if (currentAreaPlots == null) {
44-
return areas.length > 0;
45-
}
46-
if (!currentAreaPlots.hasNext()) {
47-
return ++areaIndex < areas.length - 1;
46+
if (currentAreaPlots == null || !currentAreaPlots.hasNext()) {
47+
if (areaIndex >= areas.length) {
48+
return false;
49+
}
50+
currentAreaPlots = areas[++areaIndex].getPlots().iterator();
4851
}
4952
return true;
5053
}

0 commit comments

Comments
 (0)