mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-09-24 21:02:48 +02:00
Return island protection center instead of island logical center
IslandsManager.getIslandLocation(world, uuid) is used to find the starting point for the island home if a safe home for players cannot be found. It returns the island center location but should return the center of the island protection because that can now be in a different location.
This commit is contained in:
parent
b8d9b73103
commit
87bdee0946
@ -448,19 +448,25 @@ public class IslandsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player's island location in World
|
* Returns the player's island location in World based on the island protection center.
|
||||||
* Returns an island location OR a team island location
|
* If you need the actual island center location for some reason use {@link Island#getCenter()}<p>
|
||||||
*
|
*
|
||||||
* @param world - world to check
|
* @param world - world to check
|
||||||
* @param uuid - the player's UUID
|
* @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
|
@Nullable
|
||||||
public Location getIslandLocation(@NonNull World world, @NonNull UUID uuid) {
|
public Location getIslandLocation(@NonNull World world, @NonNull UUID uuid) {
|
||||||
Island island = getIsland(world, 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) {
|
public Location getLast(@NonNull World world) {
|
||||||
return last.get(world);
|
return last.get(world);
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,8 @@ public class IslandsManagerTest {
|
|||||||
when(island.getWorld()).thenReturn(world);
|
when(island.getWorld()).thenReturn(world);
|
||||||
when(island.getMaxMembers()).thenReturn(null); // default
|
when(island.getMaxMembers()).thenReturn(null); // default
|
||||||
when(island.getMaxMembers(Mockito.anyInt())).thenReturn(null); // default
|
when(island.getMaxMembers(Mockito.anyInt())).thenReturn(null); // default
|
||||||
|
when(island.getCenter()).thenReturn(location);
|
||||||
|
when(island.getProtectionCenter()).thenReturn(location);
|
||||||
|
|
||||||
// Mock island cache
|
// Mock island cache
|
||||||
when(islandCache.getIslandAt(any(Location.class))).thenReturn(island);
|
when(islandCache.getIslandAt(any(Location.class))).thenReturn(island);
|
||||||
@ -630,8 +632,9 @@ public class IslandsManagerTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testGetIslandLocation() {
|
public void testGetIslandLocation() {
|
||||||
im.createIsland(location, uuid);
|
Island i = im.createIsland(location, uuid);
|
||||||
assertEquals(world, im.getIslandLocation(world, uuid).getWorld());
|
assertEquals(world, im.getIslandLocation(world, uuid).getWorld());
|
||||||
|
assertEquals(i.getProtectionCenter(), im.getIslandLocation(world, uuid));
|
||||||
assertNull(im.getIslandLocation(world, UUID.randomUUID()));
|
assertNull(im.getIslandLocation(world, UUID.randomUUID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user