Fix for issue where team members are sometimes not recognized.

https://github.com/BentoBoxWorld/bentobox/issues/318
This commit is contained in:
tastybento 2018-10-30 13:21:27 -07:00
parent 0346ea8a23
commit d9783c8d73
2 changed files with 21 additions and 2 deletions

View File

@ -636,8 +636,7 @@ public class IslandsManager {
}
return getProtectedIslandAt(user.getLocation())
.map(i -> i.getMembers().entrySet().stream()
.map(en -> en.getKey().equals(user.getUniqueId()) && en.getValue() > RanksManager.VISITOR_RANK)
.findAny().orElse(false))
.anyMatch(en -> en.getKey().equals(user.getUniqueId()) && en.getValue() > RanksManager.VISITOR_RANK))
.orElse(false);
}

View File

@ -830,9 +830,29 @@ public class IslandsManagerTest {
when(is.getMembers()).thenReturn(members);
assertFalse(im.userIsOnIsland(world, user));
// One member, just the owner
members.put(user.getUniqueId(), RanksManager.MEMBER_RANK);
assertTrue(im.userIsOnIsland(world, user));
// Add some members
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
members.put(UUID.randomUUID(), RanksManager.MEMBER_RANK);
assertTrue(im.userIsOnIsland(world, user));
// Add some other ranks
members.put(UUID.randomUUID(), RanksManager.BANNED_RANK);
members.put(UUID.randomUUID(), RanksManager.BANNED_RANK);
members.put(UUID.randomUUID(), RanksManager.COOP_RANK);
members.put(UUID.randomUUID(), RanksManager.TRUSTED_RANK);
members.put(UUID.randomUUID(), RanksManager.BANNED_RANK);
assertTrue(im.userIsOnIsland(world, user));
// Confirm that if user is not above Member rank then it fails
members.put(user.getUniqueId(), RanksManager.BANNED_RANK);
assertFalse(im.userIsOnIsland(world, user));
}