diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java index 78b75119..cbda2b48 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/handler/CommandHandler.java @@ -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); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java new file mode 100644 index 00000000..1181391b --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/PingServersCommand.java @@ -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); + } + } + }); + } +}