mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 19:25:12 +01:00
Handle null users when getting island. Added test case.
A recent change to placeholders meant that it is possible for users to be null. See https://github.com/BentoBoxWorld/BentoBox/issues/1654
This commit is contained in:
parent
69b40ee141
commit
97ac70cea3
@ -377,11 +377,11 @@ public class IslandsManager {
|
||||
* If they are in a team, the team island is returned.
|
||||
* @param world world to check
|
||||
* @param user user
|
||||
* @return Island or null
|
||||
* @return Island or null if not found or null user
|
||||
*/
|
||||
@Nullable
|
||||
public Island getIsland(@NonNull World world, @NonNull User user){
|
||||
return islandCache.get(world, user.getUniqueId());
|
||||
public Island getIsland(@NonNull World world, @Nullable User user){
|
||||
return user == null || user.getUniqueId() == null ? null : getIsland(world, user.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -592,6 +592,17 @@ public class IslandsManagerTest {
|
||||
assertEquals(1, im.getIslandCount());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIsland(World, User)}
|
||||
*/
|
||||
@Test
|
||||
public void testGetIslandWorldUser() {
|
||||
IslandsManager im = new IslandsManager(plugin);
|
||||
Island island = im.createIsland(location, user.getUniqueId());
|
||||
assertEquals(island, im.getIsland(world, user));
|
||||
assertNull(im.getIsland(world, (User)null));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.managers.IslandsManager#getIsland(World, UUID)}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user