Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Cap /server list to 50 servers.
Any more, and the server list is arguably useless. Thanks to BXBW for finding this particular issue!
Dieser Commit ist enthalten in:
Ursprung
feb7c2f893
Commit
91e9769c5a
@ -12,8 +12,6 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
|||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -25,6 +23,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
|
|
||||||
public class ServerCommand implements Command {
|
public class ServerCommand implements Command {
|
||||||
|
|
||||||
|
public static final int MAX_SERVERS_TO_LIST = 50;
|
||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
|
|
||||||
public ServerCommand(ProxyServer server) {
|
public ServerCommand(ProxyServer server) {
|
||||||
@ -61,10 +60,16 @@ public class ServerCommand implements Command {
|
|||||||
executor.sendMessage(of("You are currently connected to " + currentServer + ".",
|
executor.sendMessage(of("You are currently connected to " + currentServer + ".",
|
||||||
TextColor.YELLOW));
|
TextColor.YELLOW));
|
||||||
|
|
||||||
|
List<RegisteredServer> servers = BuiltinCommandUtil.sortedServerList(server);
|
||||||
|
if (servers.size() > MAX_SERVERS_TO_LIST) {
|
||||||
|
executor.sendMessage(of("Too many servers to list. Tab-complete to show all servers.",
|
||||||
|
TextColor.RED));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 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 = BuiltinCommandUtil.sortedServerList(server);
|
|
||||||
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