3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-25 15:50:19 +01:00

Improve tab completion of glist and send command (#1126)

Dieser Commit ist enthalten in:
Luccboy 2023-10-29 04:21:15 +01:00 committet von GitHub
Ursprung 81145e45df
Commit 9b71564c5b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 29 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -66,10 +66,18 @@ public class GlistCommand {
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder
.<CommandSource, String>argument(SERVER_ARG, StringArgumentType.string())
.suggests((context, builder) -> {
String argument = context.getArguments().containsKey(SERVER_ARG)
? context.getArgument(SERVER_ARG, String.class)
: "";
for (RegisteredServer server : server.getAllServers()) {
builder.suggest(server.getServerInfo().getName());
String serverName = server.getServerInfo().getName();
if (serverName.regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest(serverName);
}
}
if ("all".regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest("all");
}
builder.suggest("all");
return builder.buildFuture();
})
.executes(this::serverCount)

Datei anzeigen

@ -56,21 +56,35 @@ public class SendCommand {
.executes(this::usage)
.build();
ArgumentCommandNode<CommandSource, String> playerNode = RequiredArgumentBuilder
.<CommandSource, String>argument("player", StringArgumentType.word())
.<CommandSource, String>argument(PLAYER_ARG, StringArgumentType.word())
.suggests((context, builder) -> {
String argument = context.getArguments().containsKey(PLAYER_ARG)
? context.getArgument(PLAYER_ARG, String.class)
: "";
for (Player player : server.getAllPlayers()) {
builder.suggest(player.getUsername());
String playerName = player.getUsername();
if (playerName.regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest(playerName);
}
}
if ("all".regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest("all");
}
builder.suggest("all");
return builder.buildFuture();
})
.executes(this::usage)
.build();
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder
.<CommandSource, String>argument("server", StringArgumentType.word())
.<CommandSource, String>argument(SERVER_ARG, StringArgumentType.word())
.suggests((context, builder) -> {
String argument = context.getArguments().containsKey(SERVER_ARG)
? context.getArgument(SERVER_ARG, String.class)
: "";
for (RegisteredServer server : server.getAllServers()) {
builder.suggest(server.getServerInfo().getName());
String serverName = server.getServerInfo().getName();
if (serverName.regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest(serverName);
}
}
return builder.buildFuture();
})