diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 32b8bfd7c..bc0bfb1d8 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -448,19 +448,25 @@ public class IslandsManager { } /** - * Returns the player's island location in World - * Returns an island location OR a team island location + * Returns the player's island location in World based on the island protection center. + * If you need the actual island center location for some reason use {@link Island#getCenter()}

* * @param world - world to check * @param uuid - the player's UUID - * @return Location of player's island or null if one does not exist + * @return Location of the center of the player's protection area or null if an island does not exist. + * Returns an island location OR a team island location */ @Nullable public Location getIslandLocation(@NonNull World world, @NonNull UUID uuid) { Island island = getIsland(world, uuid); - return island != null ? island.getCenter() : null; + return island != null ? island.getProtectionCenter() : null; } + /** + * Get the last location where an island was created + * @param world - world + * @return location + */ public Location getLast(@NonNull World world) { return last.get(world); } diff --git a/src/test/java/world/bentobox/bentobox/managers/IslandsManagerTest.java b/src/test/java/world/bentobox/bentobox/managers/IslandsManagerTest.java index 63e6e9639..b52339032 100644 --- a/src/test/java/world/bentobox/bentobox/managers/IslandsManagerTest.java +++ b/src/test/java/world/bentobox/bentobox/managers/IslandsManagerTest.java @@ -238,6 +238,8 @@ public class IslandsManagerTest { when(island.getWorld()).thenReturn(world); when(island.getMaxMembers()).thenReturn(null); // default when(island.getMaxMembers(Mockito.anyInt())).thenReturn(null); // default + when(island.getCenter()).thenReturn(location); + when(island.getProtectionCenter()).thenReturn(location); // Mock island cache when(islandCache.getIslandAt(any(Location.class))).thenReturn(island); @@ -630,8 +632,9 @@ public class IslandsManagerTest { */ @Test public void testGetIslandLocation() { - im.createIsland(location, uuid); + Island i = im.createIsland(location, uuid); assertEquals(world, im.getIslandLocation(world, uuid).getWorld()); + assertEquals(i.getProtectionCenter(), im.getIslandLocation(world, uuid)); assertNull(im.getIslandLocation(world, UUID.randomUUID())); }