mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-26 04:35:43 +01:00
Fixes admin setowner and info commands for team members
https://github.com/BentoBoxWorld/BentoBox/issues/452
This commit is contained in:
parent
cd4f0c2561
commit
b51178518a
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user