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