diff --git a/src/main/java/xxAROX/PresenceMan/NukkitX/tasks/async/FetchGatewayInformationTask.java b/src/main/java/xxAROX/PresenceMan/NukkitX/tasks/async/FetchGatewayInformationTask.java index a986a11..f017e56 100644 --- a/src/main/java/xxAROX/PresenceMan/NukkitX/tasks/async/FetchGatewayInformationTask.java +++ b/src/main/java/xxAROX/PresenceMan/NukkitX/tasks/async/FetchGatewayInformationTask.java @@ -2,7 +2,6 @@ import cn.nukkit.Server; import cn.nukkit.scheduler.AsyncTask; -import com.google.gson.Gson; import com.google.gson.JsonObject; import okhttp3.*; import org.jetbrains.annotations.NotNull; @@ -32,7 +31,7 @@ public void onResponse(@NotNull Call call, @NotNull Response response) { if (response.code() == 200) { try { String responseBody = Objects.requireNonNull(response.body()).string(); - JsonObject result = parseJsonResponse(responseBody); + JsonObject result = PresenceMan.GSON.fromJson(responseBody, JsonObject.class); if (result != null && !result.isEmpty()) { Integer port = result.has("port") && !result.get("port").isJsonNull() ? result.get("port").getAsInt() : null; Gateway.protocol = result.get("protocol").getAsString(); @@ -60,11 +59,6 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) { }); } - private JsonObject parseJsonResponse(String responseBody) { - Gson gson = new Gson(); - return gson.fromJson(responseBody, JsonObject.class); - } - public static void ping_backend(Consumer callback) { if (ReconnectingTask.active) return;