Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Apply some changes from 5.0.0
Dieser Commit ist enthalten in:
Ursprung
2e8ef8b2ca
Commit
2ec830f874
@ -28,8 +28,10 @@ import com.velocitypowered.api.command.CommandSource;
|
|||||||
import com.velocitypowered.api.permission.Tristate;
|
import com.velocitypowered.api.permission.Tristate;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ public class SendCommand {
|
|||||||
.executes(this::usage)
|
.executes(this::usage)
|
||||||
.build();
|
.build();
|
||||||
ArgumentCommandNode<CommandSource, String> playerNode = RequiredArgumentBuilder
|
ArgumentCommandNode<CommandSource, String> playerNode = RequiredArgumentBuilder
|
||||||
.<CommandSource, String>argument(PLAYER_ARG, StringArgumentType.word())
|
.<CommandSource, String>argument("player", StringArgumentType.word())
|
||||||
.suggests((context, builder) -> {
|
.suggests((context, builder) -> {
|
||||||
String argument = context.getArguments().containsKey(PLAYER_ARG)
|
String argument = context.getArguments().containsKey(PLAYER_ARG)
|
||||||
? context.getArgument(PLAYER_ARG, String.class)
|
? context.getArgument(PLAYER_ARG, String.class)
|
||||||
@ -79,16 +81,10 @@ public class SendCommand {
|
|||||||
.executes(this::usage)
|
.executes(this::usage)
|
||||||
.build();
|
.build();
|
||||||
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder
|
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder
|
||||||
.<CommandSource, String>argument(SERVER_ARG, StringArgumentType.word())
|
.<CommandSource, String>argument("server", StringArgumentType.word())
|
||||||
.suggests((context, builder) -> {
|
.suggests((context, builder) -> {
|
||||||
String argument = context.getArguments().containsKey(SERVER_ARG)
|
|
||||||
? context.getArgument(SERVER_ARG, String.class)
|
|
||||||
: "";
|
|
||||||
for (RegisteredServer server : server.getAllServers()) {
|
for (RegisteredServer server : server.getAllServers()) {
|
||||||
String serverName = server.getServerInfo().getName();
|
builder.suggest(server.getServerInfo().getName());
|
||||||
if (serverName.regionMatches(true, 0, argument, 0, argument.length())) {
|
|
||||||
builder.suggest(serverName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return builder.buildFuture();
|
return builder.buildFuture();
|
||||||
})
|
})
|
||||||
@ -110,7 +106,9 @@ public class SendCommand {
|
|||||||
String serverName = context.getArgument(SERVER_ARG, String.class);
|
String serverName = context.getArgument(SERVER_ARG, String.class);
|
||||||
String player = context.getArgument(PLAYER_ARG, String.class);
|
String player = context.getArgument(PLAYER_ARG, String.class);
|
||||||
|
|
||||||
if (server.getServer(serverName).isEmpty()) {
|
Optional<RegisteredServer> maybeServer = server.getServer(serverName);
|
||||||
|
|
||||||
|
if (maybeServer.isEmpty()) {
|
||||||
context.getSource().sendMessage(
|
context.getSource().sendMessage(
|
||||||
CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))
|
CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))
|
||||||
);
|
);
|
||||||
@ -118,7 +116,8 @@ public class SendCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (server.getPlayer(player).isEmpty()
|
if (server.getPlayer(player).isEmpty()
|
||||||
&& !Objects.equals(player, "all") && !Objects.equals(player, "current")) {
|
&& !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))
|
||||||
);
|
);
|
||||||
@ -139,9 +138,10 @@ public class SendCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player source = (Player) context.getSource();
|
Player source = (Player) context.getSource();
|
||||||
if (source.getCurrentServer().isPresent()) {
|
Optional<ServerConnection> connectedServer = source.getCurrentServer();
|
||||||
for (Player p : source.getCurrentServer().get().getServer().getPlayersConnected()) {
|
if (connectedServer.isPresent()) {
|
||||||
p.createConnectionRequest(server.getServer(serverName).get()).fireAndForget();
|
for (Player p : connectedServer.get().getServer().getPlayersConnected()) {
|
||||||
|
p.createConnectionRequest(maybeServer.get()).fireAndForget();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -149,8 +149,7 @@ public class SendCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
server.getPlayer(player).get().createConnectionRequest(
|
server.getPlayer(player).get().createConnectionRequest(
|
||||||
server.getServer(serverName).get()
|
maybeServer.get()).fireAndForget();
|
||||||
).fireAndForget();
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren