[FEATURE] pingServersCommand

This commit is contained in:
Gravit 2020-11-22 17:33:37 +07:00
parent 06aa6976e0
commit f971356955
No known key found for this signature in database
GPG key ID: 98A079490768CCE5
2 changed files with 37 additions and 0 deletions

View file

@ -78,6 +78,7 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand
service.registerCommand("clients", new ClientsCommand(server));
service.registerCommand("signJar", new SignJarCommand(server));
service.registerCommand("signDir", new SignDirCommand(server));
service.registerCommand("pingServers", new PingServersCommand(server));
service.registerCommand("securitycheck", new SecurityCheckCommand(server));
Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components");
handler.registerCategory(serviceCategory);

View file

@ -0,0 +1,36 @@
package pro.gravit.launchserver.command.service;
import pro.gravit.launcher.request.management.PingServerReportRequest;
import pro.gravit.launchserver.LaunchServer;
import pro.gravit.launchserver.command.Command;
import pro.gravit.utils.helper.LogHelper;
public class PingServersCommand extends Command {
public PingServersCommand(LaunchServer server) {
super(server);
}
@Override
public String getArgsDescription() {
return "[]";
}
@Override
public String getUsageDescription() {
return "show modern pings status";
}
@Override
public void invoke(String... args) throws Exception {
server.pingServerManager.map.forEach((name, data) -> {
LogHelper.info("[%s] online %d / %d", name, data.lastReport == null ? -1 : data.lastReport.playersOnline, data.lastReport == null ? -1 : data.lastReport.maxPlayers);
if(data.lastReport != null && data.lastReport.users != null)
{
for(PingServerReportRequest.PingServerReport.UsernameInfo user : data.lastReport.users)
{
LogHelper.subInfo("User %s", user.username == null ? "null" : user.username);
}
}
});
}
}