fix: /tp TAB not serving players in arg 0, close #675

This commit is contained in:
William committed 2024-08-22 13:28:43 +01:00
1 parent 3b7bb2714a
commit 7029b50a42
1 file changed
+2 -5
@@ -128,7 +128,6 @@ public class TpCommand extends Command implements TabProvider {
public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) { public final List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
final Position relative = getBasePosition(user); final Position relative = getBasePosition(user);
final boolean serveCoordinateCompletions = user.hasPermission(getPermission("coordinates")); final boolean serveCoordinateCompletions = user.hasPermission(getPermission("coordinates"));
final boolean servePlayerCompletions = user.hasPermission(getPermission("other"));
switch (args.length) { switch (args.length) {
case 0, 1 -> { case 0, 1 -> {
final ArrayList<String> completions = Lists.newArrayList(serveCoordinateCompletions final ArrayList<String> completions = Lists.newArrayList(serveCoordinateCompletions
@@ -137,9 +136,7 @@ public class TpCommand extends Command implements TabProvider {
((int) relative.getX() + " " + (int) relative.getY()), ((int) relative.getX() + " " + (int) relative.getY()),
((int) relative.getX() + " " + (int) relative.getY() + " " + (int) relative.getZ())) ((int) relative.getX() + " " + (int) relative.getY() + " " + (int) relative.getZ()))
: List.of()); : List.of());
if (servePlayerCompletions) { completions.addAll(plugin.getPlayerList(false));
completions.addAll(plugin.getPlayerList(false));
}
return completions.stream() return completions.stream()
.filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : "")) .filter(s -> s.toLowerCase().startsWith(args.length == 1 ? args[0].toLowerCase() : ""))
.sorted().collect(Collectors.toList()); .sorted().collect(Collectors.toList());
@@ -157,7 +154,7 @@ public class TpCommand extends Command implements TabProvider {
((int) relative.getX() + " " + (int) relative.getY() + " " + (int) relative.getZ())) ((int) relative.getX() + " " + (int) relative.getY() + " " + (int) relative.getZ()))
: List.of() : List.of()
); );
if (servePlayerCompletions) { if (user.hasPermission(getPermission("other"))) {
completions.addAll(plugin.getPlayerList(false)); completions.addAll(plugin.getPlayerList(false));
} }
} }