mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] pingServersCommand
This commit is contained in:
parent
06aa6976e0
commit
f971356955
2 changed files with 37 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue