geforkt von Mirrors/Velocity
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.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
@ -56,7 +58,7 @@ public class SendCommand {
|
||||
.executes(this::usage)
|
||||
.build();
|
||||
ArgumentCommandNode<CommandSource, String> playerNode = RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument(PLAYER_ARG, StringArgumentType.word())
|
||||
.<CommandSource, String>argument("player", StringArgumentType.word())
|
||||
.suggests((context, builder) -> {
|
||||
String argument = context.getArguments().containsKey(PLAYER_ARG)
|
||||
? context.getArgument(PLAYER_ARG, String.class)
|
||||
@ -79,16 +81,10 @@ public class SendCommand {
|
||||
.executes(this::usage)
|
||||
.build();
|
||||
ArgumentCommandNode<CommandSource, String> serverNode = RequiredArgumentBuilder
|
||||
.<CommandSource, String>argument(SERVER_ARG, StringArgumentType.word())
|
||||
.<CommandSource, String>argument("server", StringArgumentType.word())
|
||||
.suggests((context, builder) -> {
|
||||
String argument = context.getArguments().containsKey(SERVER_ARG)
|
||||
? context.getArgument(SERVER_ARG, String.class)
|
||||
: "";
|
||||
for (RegisteredServer server : server.getAllServers()) {
|
||||
String serverName = server.getServerInfo().getName();
|
||||
if (serverName.regionMatches(true, 0, argument, 0, argument.length())) {
|
||||
builder.suggest(serverName);
|
||||
}
|
||||
builder.suggest(server.getServerInfo().getName());
|
||||
}
|
||||
return builder.buildFuture();
|
||||
})
|
||||
@ -110,7 +106,9 @@ public class SendCommand {
|
||||
String serverName = context.getArgument(SERVER_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(
|
||||
CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))
|
||||
);
|
||||
@ -118,7 +116,8 @@ public class SendCommand {
|
||||
}
|
||||
|
||||
if (server.getPlayer(player).isEmpty()
|
||||
&& !Objects.equals(player, "all") && !Objects.equals(player, "current")) {
|
||||
&& !Objects.equals(player, "all")
|
||||
&& !Objects.equals(player, "current")) {
|
||||
context.getSource().sendMessage(
|
||||
CommandMessages.PLAYER_NOT_FOUND.args(Component.text(player))
|
||||
);
|
||||
@ -139,9 +138,10 @@ public class SendCommand {
|
||||
}
|
||||
|
||||
Player source = (Player) context.getSource();
|
||||
if (source.getCurrentServer().isPresent()) {
|
||||
for (Player p : source.getCurrentServer().get().getServer().getPlayersConnected()) {
|
||||
p.createConnectionRequest(server.getServer(serverName).get()).fireAndForget();
|
||||
Optional<ServerConnection> connectedServer = source.getCurrentServer();
|
||||
if (connectedServer.isPresent()) {
|
||||
for (Player p : connectedServer.get().getServer().getPlayersConnected()) {
|
||||
p.createConnectionRequest(maybeServer.get()).fireAndForget();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -149,8 +149,7 @@ public class SendCommand {
|
||||
}
|
||||
|
||||
server.getPlayer(player).get().createConnectionRequest(
|
||||
server.getServer(serverName).get()
|
||||
).fireAndForget();
|
||||
maybeServer.get()).fireAndForget();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren