mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Ping error handle
This commit is contained in:
parent
ef5695f679
commit
5c374462ef
1 changed files with 7 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
||||||
package pro.gravit.launcher.client;
|
package pro.gravit.launcher.client;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import pro.gravit.launcher.profiles.ClientProfile;
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
|
@ -162,9 +163,13 @@ private Result modernPing(HInput input, HOutput output) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse JSON response
|
// Parse JSON response
|
||||||
JsonObject object = JsonParser.parseString(response).getAsJsonObject();
|
JsonElement element = JsonParser.parseString(response);
|
||||||
|
if(element.isJsonPrimitive()) {
|
||||||
|
throw new IOException(element.getAsString());
|
||||||
|
}
|
||||||
|
JsonObject object = element.getAsJsonObject();
|
||||||
if (object.has("error")) {
|
if (object.has("error")) {
|
||||||
throw new IOException(object.get("error").getAsString());
|
throw new IOException(object.get("error").getAsString()); // May be not needed?
|
||||||
}
|
}
|
||||||
JsonObject playersObject = object.get("players").getAsJsonObject();
|
JsonObject playersObject = object.get("players").getAsJsonObject();
|
||||||
int online = playersObject.get("online").getAsInt();
|
int online = playersObject.get("online").getAsInt();
|
||||||
|
|
Loading…
Reference in a new issue