mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-10 10:28:21 +01:00
Fixed IslandsManager#getSafeHomeLocation throwing NPE if world is not an island world
Fixes https://github.com/BentoBoxWorld/BentoBox/issues/1306 The method now properly returns null if the world is not an island world.
This commit is contained in:
parent
40240c7225
commit
46ba40b70d
@ -494,12 +494,17 @@ public class IslandsManager {
|
||||
* Determines a safe teleport spot on player's island or the team island
|
||||
* they belong to.
|
||||
*
|
||||
* @param world - world to check
|
||||
* @param user - the player
|
||||
* @param number - a number - starting home location e.g., 1
|
||||
* @return Location of a safe teleport spot or null if one cannot be found
|
||||
* @param world - world to check, not null
|
||||
* @param user - the player, not null
|
||||
* @param number - a number - starting home location, e.g. 1
|
||||
* @return Location of a safe teleport spot or {@code null} if one cannot be found or if the world is not an island world.
|
||||
*/
|
||||
public Location getSafeHomeLocation(@NonNull World world, @NonNull User user, int number) {
|
||||
// Check if the world is a gamemode world
|
||||
if (!plugin.getIWM().inWorld(world)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Try the numbered home location first
|
||||
Location l = plugin.getPlayers().getHomeLocation(world, user, number);
|
||||
|
||||
|
@ -693,6 +693,17 @@ public class IslandsManagerTest {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSafeHomeLocation(World, User, int)}.
|
||||
* Ensures that the method returns {@code null} if the world is not an island world.
|
||||
*/
|
||||
@Test
|
||||
public void testGetSafeHomeLocationWorldNotIslandWorld() {
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
when(iwm.inWorld(world)).thenReturn(false);
|
||||
assertNull(im.getSafeHomeLocation(world, user, 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getSpawnPoint(World)}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user