[FIX] Ping Server

This commit is contained in:
Gravita 2021-10-12 17:34:44 +07:00
parent 58dfc472ac
commit dabe2e8106
2 changed files with 4 additions and 1 deletions

View file

@ -24,7 +24,7 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti
builder.setTitle(title); builder.setTitle(title);
builder.setUuid(UUID.randomUUID()); builder.setUuid(UUID.randomUUID());
builder.setMainClass(getMainClassByVersion(version, options)); builder.setMainClass(getMainClassByVersion(version, options));
builder.setServers(List.of(new ClientProfile.ServerProfile(title, "localhost", 25535))); builder.setServers(List.of(new ClientProfile.ServerProfile(title, "localhost", 25565)));
// ------------ // ------------
builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar")); builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar"));
{ {

View file

@ -163,6 +163,9 @@ private Result modernPing(HInput input, HOutput output) throws IOException {
// Parse JSON response // Parse JSON response
JsonObject object = JsonParser.parseString(response).getAsJsonObject(); JsonObject object = JsonParser.parseString(response).getAsJsonObject();
if(object.has("error")) {
throw new IOException(object.get("error").getAsString());
}
JsonObject playersObject = object.get("players").getAsJsonObject(); JsonObject playersObject = object.get("players").getAsJsonObject();
int online = playersObject.get("online").getAsInt(); int online = playersObject.get("online").getAsInt();
int max = playersObject.get("max").getAsInt(); int max = playersObject.get("max").getAsInt();