1
0
Fork 0
forked from mc/VTools

Add /servers command

Add a command that displays all servers
This commit is contained in:
Felix 2021-05-28 10:49:27 +02:00
parent 912be12976
commit 151f95d7fa
3 changed files with 45 additions and 1 deletions

View file

@ -8,4 +8,6 @@ Tools for Velocity proxy server.
|/find|See on which server a user is|vtools.find and vtools.find.autocomplete|
|/send|Send a user to a different server|vtools.send|
|/sendall|Send all users to a specific server|vtools.sendall|
|/staffchat|Chat over multiple servers in a staff only chat|vtools.staffchat|
|/staffchat|Chat over multiple servers in a staff only chat|vtools.staffchat|
|/staffchat c:channelname|Chat over multiple servers in a staff only chat in a specific extra permissions channel|vtools.staffchat.channelname|
|/servers|List all servers|vtools.servers|

View file

@ -28,6 +28,7 @@ public class VTools {
server.getCommandManager().register(new CommandStaffChat(server), "staffchat", "sc");
server.getCommandManager().register(new CommandRestart(server), "restart");
server.getCommandManager().register(new CommandTp(server), "tps", "jump");
server.getCommandManager().register(new CommandServers(server), "servers", "allservers");
}
}

View file

@ -0,0 +1,41 @@
package de.strifel.VTools.commands;
import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.kyori.text.TextComponent;
import net.kyori.text.format.TextColor;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
import java.util.List;
public class CommandServers implements Command {
private final ProxyServer server;
public CommandServers(ProxyServer server) {
this.server = server;
}
@Override
public void execute(CommandSource commandSource, @NonNull String[] strings) {
StringBuilder servers = new StringBuilder();
for (RegisteredServer server : server.getAllServers()) {
servers.append(server.getServerInfo().getName());
servers.append(" ");
}
commandSource.sendMessage(TextComponent.of(servers.toString()).color(TextColor.YELLOW));
}
@Override
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) {
return new ArrayList<String>();
}
@Override
public boolean hasPermission(CommandSource source, @NonNull String[] args) {
return source.hasPermission("vtools.find");
}
}