diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java index 9785f07e0..05c7f21b9 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotId.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotId.java @@ -302,7 +302,7 @@ public final class PlotId { // first increase y, then x if (this.y == this.end.getY()) { this.x++; - this.y = 0; + this.y = this.start.getY(); } else { this.y++; } diff --git a/Core/src/test/java/com/plotsquared/core/plot/PlotRangeIteratorTest.java b/Core/src/test/java/com/plotsquared/core/plot/PlotRangeIteratorTest.java index 7cc86619f..605e22d7a 100644 --- a/Core/src/test/java/com/plotsquared/core/plot/PlotRangeIteratorTest.java +++ b/Core/src/test/java/com/plotsquared/core/plot/PlotRangeIteratorTest.java @@ -25,7 +25,8 @@ */ package com.plotsquared.core.plot; -import org.junit.Test; + +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.List; @@ -33,6 +34,7 @@ import java.util.NoSuchElementException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; @@ -106,4 +108,16 @@ public class PlotRangeIteratorTest { assertThrows(NoSuchElementException.class, range::next); } + @Test + public void resetYOfIteratorToStart() { + PlotId id00 = PlotId.of(0, 1); + PlotId id01 = PlotId.of(1, 2); + PlotId.PlotRangeIterator range = PlotId.PlotRangeIterator.range(id00, id01); + + for (int i = 0; i < 4; i++) { + assertNotEquals(0, range.next().getY()); + } + assertFalse(range.hasNext()); + assertThrows(NoSuchElementException.class, range::next); + } }