Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Also sort servers for /glist all
Dieser Commit ist enthalten in:
Ursprung
08173c50ef
Commit
63dcc56735
@ -0,0 +1,21 @@
|
|||||||
|
package com.velocitypowered.proxy.command;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class BuiltinCommandUtil {
|
||||||
|
|
||||||
|
private BuiltinCommandUtil() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
static List<RegisteredServer> sortedServerList(ProxyServer proxy) {
|
||||||
|
List<RegisteredServer> servers = new ArrayList<>(proxy.getAllServers());
|
||||||
|
servers.sort(Comparator.comparing(RegisteredServer::getServerInfo));
|
||||||
|
return Collections.unmodifiableList(servers);
|
||||||
|
}
|
||||||
|
}
|
@ -35,7 +35,7 @@ public class GlistCommand implements Command {
|
|||||||
} else if (args.length == 1) {
|
} else if (args.length == 1) {
|
||||||
String arg = args[0];
|
String arg = args[0];
|
||||||
if (arg.equalsIgnoreCase("all")) {
|
if (arg.equalsIgnoreCase("all")) {
|
||||||
for (RegisteredServer server : server.getAllServers()) {
|
for (RegisteredServer server : BuiltinCommandUtil.sortedServerList(server)) {
|
||||||
sendServerPlayers(source, server, true);
|
sendServerPlayers(source, server, true);
|
||||||
}
|
}
|
||||||
sendTotalProxyCount(source);
|
sendTotalProxyCount(source);
|
||||||
|
@ -63,8 +63,7 @@ public class ServerCommand implements Command {
|
|||||||
// Assemble the list of servers as components
|
// Assemble the list of servers as components
|
||||||
TextComponent.Builder serverListBuilder = TextComponent.builder("Available servers: ")
|
TextComponent.Builder serverListBuilder = TextComponent.builder("Available servers: ")
|
||||||
.color(TextColor.YELLOW);
|
.color(TextColor.YELLOW);
|
||||||
List<RegisteredServer> servers = new ArrayList<>(server.getAllServers());
|
List<RegisteredServer> servers = BuiltinCommandUtil.sortedServerList(server);
|
||||||
servers.sort(Comparator.comparing(RegisteredServer::getServerInfo));
|
|
||||||
for (int i = 0; i < servers.size(); i++) {
|
for (int i = 0; i < servers.size(); i++) {
|
||||||
RegisteredServer rs = servers.get(i);
|
RegisteredServer rs = servers.get(i);
|
||||||
serverListBuilder.append(formatServerComponent(currentServer, rs));
|
serverListBuilder.append(formatServerComponent(currentServer, rs));
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren