mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-23 16:41:42 +01:00
parent
5d3821094c
commit
13bd1bb8f3
@ -42,8 +42,7 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||
}
|
||||
// Can use if in a team
|
||||
Island is = getIslands().getPrimaryIsland(getWorld(), user.getUniqueId());
|
||||
boolean inTeam = is.getMemberSet().contains(user.getUniqueId());
|
||||
if (!inTeam) {
|
||||
if (is == null || !is.getMemberSet().contains(user.getUniqueId())) {
|
||||
user.sendMessage("general.errors.no-team");
|
||||
return false;
|
||||
}
|
||||
@ -99,6 +98,9 @@ public class IslandTeamSetownerCommand extends CompositeCommand {
|
||||
@Override
|
||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||
String lastArg = !args.isEmpty() ? args.get(args.size() - 1) : "";
|
||||
if (getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()) == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(Util.tabLimit(
|
||||
getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()).getMemberSet().stream()
|
||||
.filter(uuid -> !user.getUniqueId().equals(uuid)).map(getPlayers()::getName).toList(),
|
||||
|
@ -178,6 +178,16 @@ public class IslandTeamSetownerCommandTest {
|
||||
assertFalse(its.canExecute(user, "", List.of("gibby")));
|
||||
verify(user).sendMessage("general.errors.not-owner");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 testCanExecuteUserStringListOfStringNotInTeamNoIsland() {
|
||||
when(im.getPrimaryIsland(any(), any())).thenReturn(null);
|
||||
assertFalse(its.canExecute(user, "", List.of("gibby")));
|
||||
verify(user).sendMessage("general.errors.no-team");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)}.
|
||||
@ -309,5 +319,15 @@ public class IslandTeamSetownerCommandTest {
|
||||
when(island.getMemberSet()).thenReturn(ImmutableSet.of(target));
|
||||
assertEquals("tastybento", its.tabComplete(user, "", List.of()).get().get(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for
|
||||
* {@link world.bentobox.bentobox.api.commands.island.team.IslandTeamSetownerCommand#tabComplete(world.bentobox.bentobox.api.user.User, java.lang.String, java.util.List)}.
|
||||
*/
|
||||
@Test
|
||||
public void testTabCompleteUserStringListOfStringMemberNoIsland() {
|
||||
when(im.getPrimaryIsland(any(), any())).thenReturn(null);
|
||||
assertTrue(its.tabComplete(user, "", List.of()).isEmpty());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user