diff --git a/Towny/src/main/java/com/palmergames/bukkit/towny/object/WorldCoord.java b/Towny/src/main/java/com/palmergames/bukkit/towny/object/WorldCoord.java index 4da72225d6..105cc0ad5f 100644 --- a/Towny/src/main/java/com/palmergames/bukkit/towny/object/WorldCoord.java +++ b/Towny/src/main/java/com/palmergames/bukkit/towny/object/WorldCoord.java @@ -327,7 +327,7 @@ public Location getLowerMostCornerLocation() { * @return Location of the upper-most corner of a WorldCoord. */ public Location getUpperMostCornerLocation() { - return getCorner().add(getCellSize(), getBukkitWorld().getMaxHeight(), getCellSize()); + return getCorner().add(getCellSize() - 1, getBukkitWorld().getMaxHeight() - 1, getCellSize() - 1); } /** diff --git a/Towny/src/test/java/com/palmergames/bukkit/towny/object/WorldCoordTests.java b/Towny/src/test/java/com/palmergames/bukkit/towny/object/WorldCoordTests.java index a0dc944315..19bbd6ebd8 100644 --- a/Towny/src/test/java/com/palmergames/bukkit/towny/object/WorldCoordTests.java +++ b/Towny/src/test/java/com/palmergames/bukkit/towny/object/WorldCoordTests.java @@ -1,6 +1,7 @@ package com.palmergames.bukkit.towny.object; import be.seeseemelk.mockbukkit.MockBukkit; +import be.seeseemelk.mockbukkit.ServerMock; import com.google.common.collect.Iterables; import com.palmergames.bukkit.towny.TownySettings; import com.palmergames.util.Pair; @@ -13,9 +14,11 @@ import static org.junit.jupiter.api.Assertions.*; public class WorldCoordTests { + static ServerMock server; + @BeforeAll static void init() { - MockBukkit.getOrCreateMock(); + server = MockBukkit.getOrCreateMock(); TownySettings.loadDefaultConfig(); } @@ -49,4 +52,18 @@ void testLargerCellSizeChunkPositions() { void testSmallerCellSizes(RepetitionInfo info) { assertEquals(1, new WorldCoord("a", 0, 0).getChunkPositions(info.getCurrentRepetition()).size()); } + + @Test + void testCorners() { + int chunkX = -10; + int chunkZ = -10; + + server.addSimpleWorld("world"); + WorldCoord coord = new WorldCoord("world", chunkX, chunkZ); + assertEquals(chunkX, coord.getUpperMostCornerLocation().getChunk().getX()); + assertEquals(chunkZ, coord.getUpperMostCornerLocation().getChunk().getZ()); + + assertEquals(chunkX, coord.getLowerMostCornerLocation().getChunk().getX()); + assertEquals(chunkZ, coord.getLowerMostCornerLocation().getChunk().getZ()); + } }