Fixes admin setowner and info commands for team members

https://github.com/BentoBoxWorld/BentoBox/issues/452
This commit is contained in:
tastybento 2019-01-07 21:37:37 -08:00
parent cd4f0c2561
commit b51178518a
4 changed files with 11 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import java.util.UUID;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
public class AdminInfoCommand extends CompositeCommand {
@ -42,12 +43,14 @@ public class AdminInfoCommand extends CompositeCommand {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
return false;
}
if (!getIslands().hasIsland(getWorld(), targetUUID)) {
// Show info for this player
Island island = getIslands().getIsland(getWorld(), targetUUID);
if (island != null) {
island.showInfo(user);
return true;
} else {
user.sendMessage("general.errors.player-has-no-island");
return false;
}
// Show info for this player
getIslands().getIsland(getWorld(), targetUUID).showInfo(user);
return true;
}
}

View File

@ -33,10 +33,6 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
user.sendMessage("general.errors.unknown-player", TextVariables.NAME, args.get(0));
return false;
}
if (!getIslands().hasIsland(getWorld(), targetUUID)) {
user.sendMessage("general.errors.no-island");
return false;
}
if (!getIslands().inTeam(getWorld(), targetUUID)) {
user.sendMessage("general.errors.not-in-team");
return false;

View File

@ -150,6 +150,7 @@ public class AdminInfoCommandTest {
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(false);
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
Mockito.verify(user).sendMessage(Mockito.eq("general.errors.player-has-no-island"));
}

View File

@ -171,6 +171,9 @@ public class AdminTeamSetownerCommandTest {
*/
@Test
public void testExecuteSuccess() {
// Player is a team member, not an owner
when(im.hasIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(false);
when(im.hasIsland(Mockito.any(), Mockito.any(User.class))).thenReturn(false);
when(im.inTeam(Mockito.any(), Mockito.any())).thenReturn(true);
Island is = mock(Island.class);
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(is);