Fixes bug where coop or trusted could sethomes on other islands

https://github.com/BentoBoxWorld/BentoBox/issues/588
This commit is contained in:
tastybento 2019-03-13 00:01:23 -07:00
parent 8ad546df6f
commit 60b075c668
3 changed files with 17 additions and 16 deletions

View File

@ -28,7 +28,7 @@ public class IslandSethomeCommand extends ConfirmableCommand {
user.sendMessage("general.errors.no-island");
return false;
}
if (!getPlugin().getIslands().userIsOnIsland(user.getWorld(), user)) {
if (!getPlugin().getIslands().locationIsOnIsland(user.getPlayer(), user.getLocation())) {
user.sendMessage("commands.island.sethome.must-be-on-your-island");
return false;
}

View File

@ -797,7 +797,7 @@ public class IslandsManager {
}
/**
* Checks if an online player is in the protected area of an island he owns or he is part of.
* Checks if an online player is in the protected area of an island he owns or he is part of. i.e. rank is > VISITOR_RANK
*
* @param world the World to check. Typically this is the user's world. Does not check nether or end worlds. If null the method will always return {@code false}.
* @param user the User to check, if null or if this is not a Player the method will always return {@code false}.

View File

@ -163,6 +163,7 @@ public class IslandSethomeCommandTest {
@Test
public void testCanExecuteNotOnIsland() {
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.locationIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(false);
IslandSethomeCommand isc = new IslandSethomeCommand(ic);
assertFalse(isc.canExecute(user, "island", Collections.emptyList()));
Mockito.verify(user, Mockito.never()).sendMessage("general.errors.no-island");
@ -175,7 +176,7 @@ public class IslandSethomeCommandTest {
@Test
public void testCanExecute() {
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.userIsOnIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(true);
when(im.locationIsOnIsland(Mockito.any(), Mockito.any())).thenReturn(true);
IslandSethomeCommand isc = new IslandSethomeCommand(ic);
assertTrue(isc.canExecute(user, "island", Collections.emptyList()));
Mockito.verify(user, Mockito.never()).sendMessage("general.errors.no-island");