mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-25 18:48:15 +01:00
Fixes bug where coop or trusted could sethomes on other islands
https://github.com/BentoBoxWorld/BentoBox/issues/588
This commit is contained in:
parent
8ad546df6f
commit
60b075c668
@ -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;
|
||||
}
|
||||
|
@ -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}.
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user