mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-27 13:15:28 +01:00
parent
f333cfbe6f
commit
6100420bae
@ -1,10 +1,6 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.team;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||
@ -12,6 +8,9 @@ import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminTeamAddCommand extends CompositeCommand {
|
||||
|
||||
public AdminTeamAddCommand(CompositeCommand parent) {
|
||||
@ -68,7 +67,7 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
||||
Island teamIsland = getIslands().getIsland(getWorld(), ownerUUID);
|
||||
if (teamIsland != null) {
|
||||
getIslands().setJoinTeam(teamIsland, targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.team.add.success", TextVariables.NAME, target.getName(), "[owner]", owner.getName());
|
||||
IslandBaseEvent event = TeamEvent.builder()
|
||||
.island(teamIsland)
|
||||
.reason(TeamEvent.Reason.JOINED)
|
||||
@ -81,8 +80,5 @@ public class AdminTeamAddCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.player-has-no-island");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,6 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.team;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.events.IslandBaseEvent;
|
||||
import world.bentobox.bentobox.api.events.team.TeamEvent;
|
||||
@ -12,6 +8,9 @@ import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AdminTeamDisbandCommand extends CompositeCommand {
|
||||
|
||||
public AdminTeamDisbandCommand(CompositeCommand parent) {
|
||||
@ -66,7 +65,7 @@ public class AdminTeamDisbandCommand extends CompositeCommand {
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
});
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.team.disband.success", TextVariables.NAME, args.get(0));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,10 @@ import world.bentobox.bentobox.database.objects.Island;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Sets the owner of an island.
|
||||
* @author tastybento
|
||||
*/
|
||||
public class AdminTeamSetownerCommand extends CompositeCommand {
|
||||
|
||||
public AdminTeamSetownerCommand(CompositeCommand parent) {
|
||||
@ -47,7 +51,7 @@ public class AdminTeamSetownerCommand extends CompositeCommand {
|
||||
}
|
||||
// Make new owner
|
||||
getIslands().setOwner(getWorld(), user, targetUUID);
|
||||
user.sendMessage("general.success");
|
||||
user.sendMessage("commands.admin.team.setowner.success", TextVariables.NAME, args.get(0));
|
||||
// Fire event so add-ons know
|
||||
Island island = getIslands().getIsland(getWorld(), targetUUID);
|
||||
IslandBaseEvent event = TeamEvent.builder()
|
||||
|
@ -63,11 +63,13 @@ commands:
|
||||
description: "add player to owner's team"
|
||||
name-not-owner: "&c[name] is not the owner."
|
||||
name-has-island: "&c[name] has an island. Unregister or delete them first!"
|
||||
success: "&b[name]&ahas been added to &b[owner]&a's island."
|
||||
disband:
|
||||
parameters: "<owner>"
|
||||
description: "disband owner's team"
|
||||
use-disband-owner: "&cNot owner! Use disband [owner]"
|
||||
use-disband-owner: "&cNot owner! Use disband [owner]."
|
||||
disbanded: "&cAdmin disbanded your team!"
|
||||
success: "&b[name]&a's team has been disbanded."
|
||||
kick:
|
||||
parameters: "<team player>"
|
||||
description: "kick a player from a team"
|
||||
@ -79,7 +81,7 @@ commands:
|
||||
parameters: "<player>"
|
||||
description: "transfers island ownership to the player"
|
||||
already-owner: "&c[name] is already the owner of this island!"
|
||||
|
||||
success: "&b[name]&a is now the owner of this island."
|
||||
range:
|
||||
description: "Admin island range command"
|
||||
display:
|
||||
|
@ -1,17 +1,5 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.team;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -25,9 +13,9 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
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;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
@ -36,6 +24,18 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
@ -305,7 +305,7 @@ public class AdminTeamAddCommandTest {
|
||||
// Success
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
Mockito.verify(im).setJoinTeam(Mockito.eq(island), Mockito.eq(notUUID));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||
Mockito.verify(user).sendMessage("commands.admin.team.add.success", TextVariables.NAME, name[1], "[owner]", name[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,5 @@
|
||||
package world.bentobox.bentobox.api.commands.admin.team;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -27,9 +13,9 @@ import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
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;
|
||||
import world.bentobox.bentobox.managers.CommandsManager;
|
||||
@ -38,6 +24,20 @@ import world.bentobox.bentobox.managers.IslandsManager;
|
||||
import world.bentobox.bentobox.managers.LocalesManager;
|
||||
import world.bentobox.bentobox.managers.PlayersManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author tastybento
|
||||
*
|
||||
@ -123,10 +123,8 @@ public class AdminTeamDisbandCommandTest {
|
||||
PluginManager pim = mock(PluginManager.class);
|
||||
when(server.getPluginManager()).thenReturn(pim);
|
||||
when(Bukkit.getServer()).thenReturn(server);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test method for {@link AdminTeamDisbandCommand#execute(User, String, List)}.
|
||||
*/
|
||||
@ -190,6 +188,7 @@ public class AdminTeamDisbandCommandTest {
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(is);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||
when(pm.getName(Mockito.any())).thenReturn(name[0]);
|
||||
// Owner
|
||||
when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(notUUID);
|
||||
// Members
|
||||
@ -202,7 +201,6 @@ public class AdminTeamDisbandCommandTest {
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
Mockito.verify(im, Mockito.never()).setLeaveTeam(Mockito.any(), Mockito.eq(notUUID));
|
||||
Mockito.verify(im).setLeaveTeam(Mockito.any(), Mockito.eq(uuid));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||
Mockito.verify(user).sendMessage("commands.admin.team.disband.success", TextVariables.NAME, name[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -189,6 +189,7 @@ public class AdminTeamSetownerCommandTest {
|
||||
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(is);
|
||||
String[] name = {"tastybento"};
|
||||
when(pm.getUUID(Mockito.any())).thenReturn(notUUID);
|
||||
when(pm.getName(Mockito.any())).thenReturn(name[0]);
|
||||
// Owner
|
||||
when(im.getOwner(Mockito.any(), Mockito.eq(notUUID))).thenReturn(uuid);
|
||||
when(pm.getName(Mockito.eq(uuid))).thenReturn("owner");
|
||||
@ -202,7 +203,6 @@ public class AdminTeamSetownerCommandTest {
|
||||
assertTrue(itl.execute(user, itl.getLabel(), Arrays.asList(name)));
|
||||
// Add other verifications
|
||||
Mockito.verify(im).setOwner(Mockito.any(), Mockito.eq(user), Mockito.eq(notUUID));
|
||||
Mockito.verify(user).sendMessage(Mockito.eq("general.success"));
|
||||
Mockito.verify(user).sendMessage("commands.admin.team.setowner.success", TextVariables.NAME, name[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user