Skip to content

Commit

Permalink
Remove island number check for owner transfer.
Browse files Browse the repository at this point in the history
This is not needed anymore (we think).
  • Loading branch information
tastybento committed Oct 21, 2023
1 parent af3b0bb commit e4836b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,14 +63,6 @@ public boolean canExecute(User user, String label, List<String> 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

/**
Expand All @@ -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)}.
*/
Expand Down

0 comments on commit e4836b9

Please sign in to comment.