mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 19:25:12 +01:00
Adjusts tabComplete for a number of commands.
Enforces the need to type at least one letter for whole-server tab completes.
This commit is contained in:
parent
c1ede3c66a
commit
ea4ef1e21a
@ -128,7 +128,8 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
if (args.isEmpty()) {
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
if (lastArg.isEmpty()) {
|
||||||
// Don't show every player on the server. Require at least the first letter
|
// Don't show every player on the server. Require at least the first letter
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
@ -139,7 +140,6 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
.filter(p -> !island.isBanned(p.getUniqueId()))
|
.filter(p -> !island.isBanned(p.getUniqueId()))
|
||||||
.filter(p -> user.getPlayer().canSee(p))
|
.filter(p -> user.getPlayer().canSee(p))
|
||||||
.map(Player::getName).collect(Collectors.toList());
|
.map(Player::getName).collect(Collectors.toList());
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
} else {
|
} else {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
@ -2,9 +2,12 @@ package world.bentobox.bentobox.api.commands.island;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
@ -13,6 +16,7 @@ import world.bentobox.bentobox.api.events.island.IslandEvent;
|
|||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
@ -140,4 +144,19 @@ public class IslandExpelCommand extends CompositeCommand {
|
|||||||
user.sendMessage(CANNOT_EXPEL);
|
user.sendMessage(CANNOT_EXPEL);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
|
List<String> options = island.getPlayersOnIsland().stream()
|
||||||
|
.filter(p -> !p.equals(user.getPlayer()))
|
||||||
|
.map(Player::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package world.bentobox.bentobox.api.commands.island;
|
package world.bentobox.bentobox.api.commands.island;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
@ -56,4 +59,15 @@ public class IslandInfoCommand extends CompositeCommand {
|
|||||||
island.showInfo(user);
|
island.showInfo(user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
if (lastArg.isEmpty()) {
|
||||||
|
// Don't show every player on the server. Require at least the first letter
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
List<String> options = new ArrayList<>(Util.getOnlinePlayerList(user));
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,11 +118,11 @@ public class IslandTeamCoopCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
if (args.isEmpty()) {
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
if (lastArg.isEmpty()) {
|
||||||
// Don't show every player on the server. Require at least the first letter
|
// Don't show every player on the server. Require at least the first letter
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
String lastArg = args.get(args.size()-1);
|
|
||||||
return Optional.of(Util.tabLimit(Util.getOnlinePlayerList(user), lastArg));
|
return Optional.of(Util.tabLimit(Util.getOnlinePlayerList(user), lastArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public class IslandTeamInviteCommand extends CompositeCommand {
|
|||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
if (args.isEmpty()) {
|
if (lastArg.isEmpty()) {
|
||||||
// Don't show every player on the server. Require at least the first letter
|
// Don't show every player on the server. Require at least the first letter
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,11 @@ package world.bentobox.bentobox.api.commands.island.team;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
import world.bentobox.bentobox.api.events.island.IslandEvent;
|
||||||
@ -9,6 +14,7 @@ import world.bentobox.bentobox.api.localization.TextVariables;
|
|||||||
import world.bentobox.bentobox.api.user.User;
|
import world.bentobox.bentobox.api.user.User;
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
import world.bentobox.bentobox.managers.RanksManager;
|
import world.bentobox.bentobox.managers.RanksManager;
|
||||||
|
import world.bentobox.bentobox.util.Util;
|
||||||
|
|
||||||
public class IslandTeamPromoteCommand extends CompositeCommand {
|
public class IslandTeamPromoteCommand extends CompositeCommand {
|
||||||
|
|
||||||
@ -113,4 +119,18 @@ public class IslandTeamPromoteCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
|
List<String> options = island.getMemberSet().stream()
|
||||||
|
.map(Bukkit::getOfflinePlayer)
|
||||||
|
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,11 +120,11 @@ public class IslandTeamTrustCommand extends CompositeCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
if (args.isEmpty()) {
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
|
if (lastArg.isEmpty()) {
|
||||||
// Don't show every player on the server. Require at least the first letter
|
// Don't show every player on the server. Require at least the first letter
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
String lastArg = args.get(args.size()-1);
|
|
||||||
return Optional.of(Util.tabLimit(Util.getOnlinePlayerList(user), lastArg));
|
return Optional.of(Util.tabLimit(Util.getOnlinePlayerList(user), lastArg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,11 +111,10 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
|
|||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
List<String> options = island.getMemberSet().stream()
|
List<String> options = island.getMembers().entrySet().stream()
|
||||||
.filter(uuid -> island.getRank(uuid) == RanksManager.COOP_RANK)
|
.filter(e -> e.getValue() == RanksManager.COOP_RANK)
|
||||||
.map(Bukkit::getOfflinePlayer)
|
.map(e -> Bukkit.getOfflinePlayer(e.getKey()))
|
||||||
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,11 +111,10 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
|
|||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
if (island != null) {
|
if (island != null) {
|
||||||
List<String> options = island.getMemberSet().stream()
|
List<String> options = island.getMembers().entrySet().stream()
|
||||||
.filter(uuid -> island.getRank(uuid) == RanksManager.TRUSTED_RANK)
|
.filter(e -> e.getValue() == RanksManager.TRUSTED_RANK)
|
||||||
.map(Bukkit::getOfflinePlayer)
|
.map(e -> Bukkit.getOfflinePlayer(e.getKey()))
|
||||||
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
.map(OfflinePlayer::getName).collect(Collectors.toList());
|
||||||
|
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
} else {
|
} else {
|
||||||
|
@ -381,18 +381,14 @@ public class IslandBanCommandTest {
|
|||||||
LinkedList<String> args = new LinkedList<>();
|
LinkedList<String> args = new LinkedList<>();
|
||||||
args.add("");
|
args.add("");
|
||||||
result = ibc.tabComplete(user, "", args);
|
result = ibc.tabComplete(user, "", args);
|
||||||
assertTrue(result.isPresent());
|
assertFalse(result.isPresent());
|
||||||
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
|
|
||||||
// Compare the expected with the actual
|
|
||||||
String[] expectedNames = {"dave", "ed", "frank", "freddy", "george", "harry", "joe"};
|
|
||||||
assertTrue(Arrays.equals(expectedNames, r.toArray()));
|
|
||||||
|
|
||||||
// Get the tab-complete list with one letter argument
|
// Get the tab-complete list with one letter argument
|
||||||
args = new LinkedList<>();
|
args = new LinkedList<>();
|
||||||
args.add("d");
|
args.add("d");
|
||||||
result = ibc.tabComplete(user, "", args);
|
result = ibc.tabComplete(user, "", args);
|
||||||
assertTrue(result.isPresent());
|
assertTrue(result.isPresent());
|
||||||
r = result.get().stream().sorted().collect(Collectors.toList());
|
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
|
||||||
// Compare the expected with the actual
|
// Compare the expected with the actual
|
||||||
String[] expectedName = {"dave"};
|
String[] expectedName = {"dave"};
|
||||||
assertTrue(Arrays.equals(expectedName, r.toArray()));
|
assertTrue(Arrays.equals(expectedName, r.toArray()));
|
||||||
|
@ -15,6 +15,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -32,9 +33,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
import org.powermock.reflect.Whitebox;
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.Settings;
|
import world.bentobox.bentobox.Settings;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
@ -261,30 +259,24 @@ public class IslandTeamUncoopCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testTabCompleteNoArgument() {
|
public void testTabCompleteNoArgument() {
|
||||||
|
|
||||||
Builder<UUID> memberSet = new ImmutableSet.Builder<>();
|
Map<UUID, Integer> map = new HashMap<>();
|
||||||
for (int j = 0; j < 11; j++) {
|
map.put(UUID.randomUUID(),RanksManager.COOP_RANK);
|
||||||
memberSet.add(UUID.randomUUID());
|
map.put(UUID.randomUUID(),RanksManager.COOP_RANK);
|
||||||
}
|
map.put(UUID.randomUUID(),RanksManager.COOP_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
|
||||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
when(island.getMembers()).thenReturn(map);
|
||||||
// Return a set of players
|
// Return a set of players
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
||||||
when(island.getRank(any(UUID.class))).thenReturn(
|
|
||||||
RanksManager.COOP_RANK,
|
|
||||||
RanksManager.COOP_RANK,
|
|
||||||
RanksManager.COOP_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK
|
|
||||||
);
|
|
||||||
|
|
||||||
IslandTeamUncoopCommand ibc = new IslandTeamUncoopCommand(ic);
|
IslandTeamUncoopCommand ibc = new IslandTeamUncoopCommand(ic);
|
||||||
// Get the tab-complete list with no argument
|
// Get the tab-complete list with no argument
|
||||||
@ -301,30 +293,25 @@ public class IslandTeamUncoopCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testTabCompleteWithArgument() {
|
public void testTabCompleteWithArgument() {
|
||||||
|
|
||||||
Builder<UUID> memberSet = new ImmutableSet.Builder<>();
|
Map<UUID, Integer> map = new HashMap<>();
|
||||||
for (int j = 0; j < 11; j++) {
|
map.put(UUID.randomUUID(),RanksManager.COOP_RANK);
|
||||||
memberSet.add(UUID.randomUUID());
|
map.put(UUID.randomUUID(),RanksManager.COOP_RANK);
|
||||||
}
|
map.put(UUID.randomUUID(),RanksManager.COOP_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
|
||||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
when(island.getMembers()).thenReturn(map);
|
||||||
// Return a set of players
|
// Return a set of players
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
||||||
when(island.getRank(any(UUID.class))).thenReturn(
|
|
||||||
RanksManager.COOP_RANK,
|
|
||||||
RanksManager.COOP_RANK,
|
|
||||||
RanksManager.COOP_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK
|
|
||||||
);
|
|
||||||
|
|
||||||
IslandTeamUncoopCommand ibc = new IslandTeamUncoopCommand(ic);
|
IslandTeamUncoopCommand ibc = new IslandTeamUncoopCommand(ic);
|
||||||
// Get the tab-complete list with argument
|
// Get the tab-complete list with argument
|
||||||
|
@ -14,6 +14,7 @@ import java.util.Collections;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -31,9 +32,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
import org.powermock.reflect.Whitebox;
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.ImmutableSet.Builder;
|
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.Settings;
|
import world.bentobox.bentobox.Settings;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
@ -260,30 +258,24 @@ public class IslandTeamUntrustCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testTabCompleteNoArgument() {
|
public void testTabCompleteNoArgument() {
|
||||||
|
|
||||||
Builder<UUID> memberSet = new ImmutableSet.Builder<>();
|
Map<UUID, Integer> map = new HashMap<>();
|
||||||
for (int j = 0; j < 11; j++) {
|
map.put(UUID.randomUUID(),RanksManager.TRUSTED_RANK);
|
||||||
memberSet.add(UUID.randomUUID());
|
map.put(UUID.randomUUID(),RanksManager.TRUSTED_RANK);
|
||||||
}
|
map.put(UUID.randomUUID(),RanksManager.TRUSTED_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
|
||||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
when(island.getMembers()).thenReturn(map);
|
||||||
// Return a set of players
|
// Return a set of players
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
||||||
when(island.getRank(any(UUID.class))).thenReturn(
|
|
||||||
RanksManager.TRUSTED_RANK,
|
|
||||||
RanksManager.TRUSTED_RANK,
|
|
||||||
RanksManager.TRUSTED_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK
|
|
||||||
);
|
|
||||||
|
|
||||||
IslandTeamUntrustCommand ibc = new IslandTeamUntrustCommand(ic);
|
IslandTeamUntrustCommand ibc = new IslandTeamUntrustCommand(ic);
|
||||||
// Get the tab-complete list with no argument
|
// Get the tab-complete list with no argument
|
||||||
@ -300,30 +292,24 @@ public class IslandTeamUntrustCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testTabCompleteWithArgument() {
|
public void testTabCompleteWithArgument() {
|
||||||
|
|
||||||
Builder<UUID> memberSet = new ImmutableSet.Builder<>();
|
Map<UUID, Integer> map = new HashMap<>();
|
||||||
for (int j = 0; j < 11; j++) {
|
map.put(UUID.randomUUID(),RanksManager.TRUSTED_RANK);
|
||||||
memberSet.add(UUID.randomUUID());
|
map.put(UUID.randomUUID(),RanksManager.TRUSTED_RANK);
|
||||||
}
|
map.put(UUID.randomUUID(),RanksManager.TRUSTED_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
map.put(UUID.randomUUID(),RanksManager.MEMBER_RANK);
|
||||||
|
|
||||||
when(island.getMemberSet()).thenReturn(memberSet.build());
|
when(island.getMembers()).thenReturn(map);
|
||||||
// Return a set of players
|
// Return a set of players
|
||||||
PowerMockito.mockStatic(Bukkit.class);
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||||
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
when(Bukkit.getOfflinePlayer(any(UUID.class))).thenReturn(offlinePlayer);
|
||||||
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
||||||
when(island.getRank(any(UUID.class))).thenReturn(
|
|
||||||
RanksManager.TRUSTED_RANK,
|
|
||||||
RanksManager.TRUSTED_RANK,
|
|
||||||
RanksManager.TRUSTED_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK,
|
|
||||||
RanksManager.MEMBER_RANK
|
|
||||||
);
|
|
||||||
|
|
||||||
IslandTeamUntrustCommand ibc = new IslandTeamUntrustCommand(ic);
|
IslandTeamUntrustCommand ibc = new IslandTeamUntrustCommand(ic);
|
||||||
// Get the tab-complete list with argument
|
// Get the tab-complete list with argument
|
||||||
|
Loading…
Reference in New Issue
Block a user