diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java index a9f76c2e1..592445062 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommand.java @@ -13,7 +13,6 @@ import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.managers.RanksManager; -import world.bentobox.bentobox.util.IslandInfo; import world.bentobox.bentobox.util.Util; /** @@ -79,7 +78,7 @@ public boolean execute(User user, String label, @NonNull List args) { .rankChange(island.getRank(target), RanksManager.VISITOR_RANK).build(); } }); - user.sendRawMessage("Player removed from all teams in this world"); + user.sendMessage("commands.admin.team.kick.success-all"); return true; } diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index c3a201ecd..43e180e4e 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -159,6 +159,7 @@ commands: not-in-team: '&c This player is not in a team.' admin-kicked: '&c The admin kicked you from the team.' success: '&b [name] &a has been kicked from &b [owner]&a ''s island.' + success-all: '&b Player removed from all teams in this world' setowner: parameters: description: transfers island ownership to the player diff --git a/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java index d860d0e18..5c57bc793 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/admin/team/AdminTeamKickCommandTest.java @@ -68,6 +68,10 @@ public class AdminTeamKickCommandTest { private World world; @Mock private PluginManager pim; + @Mock + private Island island; + @Mock + private Island island2; /** */ @@ -106,9 +110,14 @@ public void setUp() throws Exception { IslandWorldManager iwm = mock(IslandWorldManager.class); when(plugin.getIWM()).thenReturn(iwm); + // Island + when(island.getOwner()).thenReturn(uuid); + when(island2.getOwner()).thenReturn(notUUID); + // Player has island to begin with when(im.hasIsland(any(), any(UUID.class))).thenReturn(true); when(im.hasIsland(any(), any(User.class))).thenReturn(true); + when(im.getIslands(world, uuid)).thenReturn(List.of(island, island2)); // when(im.isOwner(any(),any())).thenReturn(true); // when(im.getOwner(any(),any())).thenReturn(uuid); when(plugin.getIslands()).thenReturn(im); @@ -172,46 +181,21 @@ public void testCanExecutePlayerNotInTeam() { verify(user).sendMessage(eq("commands.admin.team.kick.not-in-team")); } - /** - * Test method for {@link AdminTeamKickCommand#execute(User, String, List)} . - */ - @Test - public void testExecuteKickOwner() { - when(im.inTeam(any(), any())).thenReturn(true); - Island is = mock(Island.class); - when(im.getIsland(any(), any(UUID.class))).thenReturn(is); - when(pm.getUUID(any())).thenReturn(notUUID); - - when(is.getOwner()).thenReturn(notUUID); - - AdminTeamKickCommand itl = new AdminTeamKickCommand(ac); - assertTrue(itl.canExecute(user, itl.getLabel(), Collections.singletonList("tastybento"))); - assertFalse(itl.execute(user, itl.getLabel(), Collections.singletonList("tastybento"))); - verify(user).sendMessage(eq("commands.admin.team.kick.cannot-kick-owner")); - verify(user).sendMessage("commands.admin.info.team-members-title"); - verify(im, never()).removePlayer(eq(world), eq(notUUID)); - verify(user, never()).sendMessage(eq("commands.admin.team.kick.success"), anyString(), anyString(), anyString(), anyString()); - verify(pim, never()).callEvent(any()); - } - /** * Test method for {@link world.bentobox.bentobox.api.commands.admin.team.AdminTeamKickCommand#execute(User, String, List)}. */ @Test public void testExecute() { when(im.inTeam(any(), any())).thenReturn(true); - Island is = mock(Island.class); - when(im.getIsland(any(), any(UUID.class))).thenReturn(is); String name = "tastybento"; - when(pm.getUUID(any())).thenReturn(notUUID); + when(pm.getUUID(any())).thenReturn(uuid); when(pm.getName(any())).thenReturn(name); - when(is.getOwner()).thenReturn(uuid); - AdminTeamKickCommand itl = new AdminTeamKickCommand(ac); assertTrue(itl.canExecute(user, itl.getLabel(), Collections.singletonList(name))); assertTrue(itl.execute(user, itl.getLabel(), Collections.singletonList(name))); - verify(im).removePlayer(is, notUUID); + verify(im, never()).removePlayer(island, uuid); + verify(im).removePlayer(island2, uuid); verify(user).sendMessage(eq("commands.admin.team.kick.success"), eq(TextVariables.NAME), eq(name), eq("[owner]"), anyString()); // Offline so event will be called 4 times verify(pim, times(4)).callEvent(any());