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

Allow sending all players from current server (#1133)

Dieser Commit ist enthalten in:
Luccboy 2023-10-29 19:42:40 +01:00 committet von GitHub
Ursprung 67d5e77b1f
Commit f87b05a487
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -70,6 +70,10 @@ public class SendCommand {
if ("all".regionMatches(true, 0, argument, 0, argument.length())) { if ("all".regionMatches(true, 0, argument, 0, argument.length())) {
builder.suggest("all"); builder.suggest("all");
} }
if ("current".regionMatches(true, 0, argument, 0, argument.length())
&& context.getSource() instanceof Player) {
builder.suggest("current");
}
return builder.buildFuture(); return builder.buildFuture();
}) })
.executes(this::usage) .executes(this::usage)
@ -113,7 +117,8 @@ public class SendCommand {
return 0; return 0;
} }
if (server.getPlayer(player).isEmpty() && !Objects.equals(player, "all")) { if (server.getPlayer(player).isEmpty()
&& !Objects.equals(player, "all") && !Objects.equals(player, "current")) {
context.getSource().sendMessage( context.getSource().sendMessage(
CommandMessages.PLAYER_NOT_FOUND.args(Component.text(player)) CommandMessages.PLAYER_NOT_FOUND.args(Component.text(player))
); );
@ -127,6 +132,22 @@ public class SendCommand {
return 1; return 1;
} }
if (Objects.equals(player, "current")) {
if (!(context.getSource() instanceof Player)) {
context.getSource().sendMessage(CommandMessages.PLAYERS_ONLY);
return 0;
}
Player source = (Player) context.getSource();
if (source.getCurrentServer().isPresent()) {
for (Player p : source.getCurrentServer().get().getServer().getPlayersConnected()) {
p.createConnectionRequest(server.getServer(serverName).get()).fireAndForget();
}
return 1;
}
return 0;
}
server.getPlayer(player).get().createConnectionRequest( server.getPlayer(player).get().createConnectionRequest(
server.getServer(serverName).get() server.getServer(serverName).get()
).fireAndForget(); ).fireAndForget();