diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java index 981dc9af5..5383cdfee 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java @@ -6,7 +6,6 @@ import org.eclipse.jdt.annotation.Nullable; -import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.island.IslandEvent; @@ -64,14 +63,6 @@ public boolean canExecute(User user, String label, List args) { user.sendMessage("commands.island.team.setowner.errors.target-is-not-member"); return false; } - // Check how many islands target has - int num = getIslands().getNumberOfConcurrentIslands(targetUUID, getWorld()); - int max = user.getPermissionValue(this.getIWM().getAddon(getWorld()).map(GameModeAddon::getPermissionPrefix).orElse("") + "island.number", this.getIWM().getWorldSettings(getWorld()).getConcurrentIslands()); - if (num >= max) { - // Too many - user.sendMessage("commands.island.team.setowner.errors.at-max"); - return false; - } return true; } diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommandTest.java index b67c9067e..324a50776 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommandTest.java @@ -230,23 +230,23 @@ public void testCanExecuteUserStringListOfStringSamePlayer() { } /** - * Test method for {@link world.bentobox.bentobox.api.commands.island.team.IslandTeamSetownerCommand#canExecute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. + * test method for {@link world.bentobox.bentobox.api.commands.island.team.islandteamsetownercommand#canexecute(world.bentobox.bentobox.api.user.user, java.lang.string, java.util.list)}. */ - @Test - public void testCanExecuteUserStringListOfStringTargetAtMaxIslands() { - when(im.inTeam(any(), any())).thenReturn(true); - when(im.getOwner(any(), any())).thenReturn(uuid); - UUID target = UUID.randomUUID(); - when(pm.getUUID(anyString())).thenReturn(target); - when(im.getMembers(any(), any())).thenReturn(Set.of(target)); - @Nullable - Island island = mock(Island.class); - when(im.getIsland(any(), any(User.class))).thenReturn(island); - - when(im.getNumberOfConcurrentIslands(target, world)).thenReturn(3); - - assertFalse(its.canExecute(user, "", List.of("tastybento"))); - verify(user).sendMessage("commands.island.team.setowner.errors.at-max"); + @test + public void testcanexecuteuserstringlistofstringtargetatmaxislands() { + when(im.inteam(any(), any())).thenreturn(true); + when(im.getowner(any(), any())).thenreturn(uuid); + uuid target = uuid.randomuuid(); + when(pm.getuuid(anystring())).thenreturn(target); + when(im.getmembers(any(), any())).thenreturn(set.of(target)); + @nullable + island island = mock(island.class); + when(im.getisland(any(), any(user.class))).thenreturn(island); + + when(im.getnumberofconcurrentislands(target, world)).thenreturn(3); + + assertfalse(its.canexecute(user, "", list.of("tastybento"))); + verify(user).sendmessage("commands.island.team.setowner.errors.at-max"); } /** @@ -262,24 +262,6 @@ public void testCanExecuteUserStringListOfStringTargetNotInTeam() { verify(user).sendMessage("commands.island.team.setowner.errors.target-is-not-member"); } - /** - * Test method for {@link world.bentobox.bentobox.api.commands.island.team.IslandTeamSetownerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. - */ - @Test - public void testExecuteUserStringListOfStringTooManyConcurrent() { - when(im.getNumberOfConcurrentIslands(any(), eq(world))).thenReturn(20); - when(im.inTeam(any(), any())).thenReturn(true); - when(im.getOwner(any(), any())).thenReturn(uuid); - UUID target = UUID.randomUUID(); - when(pm.getUUID(anyString())).thenReturn(target); - when(im.getMembers(any(), any())).thenReturn(Set.of(target)); - @Nullable - Island island = mock(Island.class); - when(im.getIsland(any(), any(User.class))).thenReturn(island); - assertFalse(its.canExecute(user, "", List.of("tastybento"))); - verify(user).sendMessage("commands.island.team.setowner.errors.at-max"); - } - /** * Test method for {@link world.bentobox.bentobox.api.commands.island.team.IslandTeamSetownerCommand#execute(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}. */