mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-13 03:40:45 +01:00
Renamed AdminTeamMakeLeaderCommand to AdminTeamSetOwnerCommand
This commit is contained in:
parent
cc2bbfc447
commit
13c483e5eb
@ -1,23 +1,23 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.team;
|
||||
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
public class AdminTeamMakeLeaderCommand extends CompositeCommand {
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public AdminTeamMakeLeaderCommand(CompositeCommand parent) {
|
||||
super(parent, "makeleader");
|
||||
public class AdminTeamSetOwnerCommand extends CompositeCommand {
|
||||
|
||||
public AdminTeamSetOwnerCommand(CompositeCommand parent) {
|
||||
super(parent, "setowner");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
setPermission("admin.team");
|
||||
setParametersHelp("commands.admin.team.makeleader.parameters");
|
||||
setDescription("commands.admin.team.makeleader.description");
|
||||
setParametersHelp("commands.admin.team.setowner.parameters");
|
||||
setDescription("commands.admin.team.setowner.description");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -42,12 +42,12 @@ public class AdminTeamMakeLeaderCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
if (getIslands().getTeamLeader(getWorld(), targetUUID).equals(targetUUID)) {
|
||||
user.sendMessage("commands.admin.team.makeleader.already-leader");
|
||||
user.sendMessage("commands.admin.team.setowner.already-owner");
|
||||
return false;
|
||||
}
|
||||
// Make new leader
|
||||
// Make new owner
|
||||
getIslands().setOwner(getWorld(), user, targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -70,10 +70,10 @@ commands:
|
||||
description: "kick a player from a team"
|
||||
cannot-kick-leader: "&cYou cannot kick the team leader. Kick members first"
|
||||
admin-kicked: "&cThe admin kicked you from the team."
|
||||
makeleader:
|
||||
setowner:
|
||||
parameters: "<player>"
|
||||
description: "make player the team's leader"
|
||||
already-leader: "&cPlayer is already the leader!"
|
||||
description: "transfers island ownership to the player"
|
||||
already-owner: "&cPlayer is already the owner of this island!"
|
||||
range:
|
||||
description: "Admin island range command"
|
||||
display:
|
||||
|
@ -41,7 +41,7 @@ import world.bentobox.bentobox.managers.PlayersManager;
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({Bukkit.class, BentoBox.class, User.class })
|
||||
public class AdminTeamMakeLeaderCommandTest {
|
||||
public class AdminTeamSetOwnerCommandTest {
|
||||
|
||||
private CompositeCommand ac;
|
||||
private UUID uuid;
|
||||
@ -114,21 +114,21 @@ public class AdminTeamMakeLeaderCommandTest {
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamSetOwnerCommand#execute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteNoTarget() {
|
||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||
AdminTeamSetOwnerCommand itl = new AdminTeamSetOwnerCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>()));
|
||||
// Show help
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamSetOwnerCommand#execute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteUnknownPlayer() {
|
||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||
AdminTeamSetOwnerCommand itl = new AdminTeamSetOwnerCommand(ac);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(null);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
@ -136,11 +136,11 @@ public class AdminTeamMakeLeaderCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamSetOwnerCommand#execute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecutePlayerNotInTeam() {
|
||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||
AdminTeamSetOwnerCommand itl = new AdminTeamSetOwnerCommand(ac);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(new HashSet<>());
|
||||
@ -149,7 +149,7 @@ public class AdminTeamMakeLeaderCommandTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamSetOwnerCommand#execute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteMakeLeaderAlreadyLeader() {
|
||||
@ -161,13 +161,13 @@ public class AdminTeamMakeLeaderCommandTest {
|
||||
|
||||
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
|
||||
|
||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||
AdminTeamSetOwnerCommand itl = new AdminTeamSetOwnerCommand(ac);
|
||||
assertFalse(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
Mockito.verify(user).sendMessage("commands.admin.team.makeleader.already-leader");
|
||||
Mockito.verify(user).sendMessage("commands.admin.team.setowner.already-owner");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamMakeLeaderCommand#execute(User, String, List)}.
|
||||
* Test method for {@link AdminTeamSetOwnerCommand#execute(User, String, List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testExecuteSuccess() {
|
||||
@ -178,14 +178,14 @@ public class AdminTeamMakeLeaderCommandTest {
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||
// Leader
|
||||
when(im.getTeamLeader(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
|
||||
when(pm.getName(Mockito.eq(uuid))).thenReturn("leader");
|
||||
when(pm.getName(Mockito.eq(uuid))).thenReturn("owner");
|
||||
// Members
|
||||
Set<UUID> members = new HashSet<>();
|
||||
members.add(uuid);
|
||||
members.add(notUUID);
|
||||
when(im.getMembers(Mockito.any(), Mockito.any())).thenReturn(members);
|
||||
|
||||
AdminTeamMakeLeaderCommand itl = new AdminTeamMakeLeaderCommand(ac);
|
||||
AdminTeamSetOwnerCommand itl = new AdminTeamSetOwnerCommand(ac);
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
// Add other verifications
|
||||
Mockito.verify(im).setOwner(Mockito.any(), Mockito.eq(user), Mockito.eq(notUUID));
|
Loading…
Reference in New Issue
Block a user