mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-04-02 01:36:25 +02:00
chore/fix: update iterator
This commit is contained in:
parent
36de196d3d
commit
30867354cc
@ -35,16 +35,19 @@ interface PlotProvider {
|
||||
Stream<Plot> streamPlots();
|
||||
|
||||
default Stream<Plot> streamPlotsInPlotAreas(PlotArea[] areas) {
|
||||
if (areas == null || areas.length == 0) {
|
||||
return Stream.of();
|
||||
}
|
||||
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new Iterator<>() {
|
||||
private int areaIndex = -1;
|
||||
private Iterator<Plot> currentAreaPlots;
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (currentAreaPlots == null) {
|
||||
return areas.length > 0;
|
||||
}
|
||||
if (!currentAreaPlots.hasNext()) {
|
||||
return ++areaIndex < areas.length - 1;
|
||||
if (currentAreaPlots == null || !currentAreaPlots.hasNext()) {
|
||||
if (areaIndex >= areas.length) {
|
||||
return false;
|
||||
}
|
||||
currentAreaPlots = areas[++areaIndex].getPlots().iterator();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user