✨ Add /servers command
Add a command that displays all servers
This commit is contained in:
parent
912be12976
commit
151f95d7fa
3 changed files with 45 additions and 1 deletions
|
@ -9,3 +9,5 @@ Tools for Velocity proxy server.
|
|||
|/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 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|
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
41
src/main/java/de/strifel/VTools/commands/CommandServers.java
Normal file
41
src/main/java/de/strifel/VTools/commands/CommandServers.java
Normal 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");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue