Skip to content

Commit

Permalink
fix: fix JsonParser static methods not exist before 1.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 committed Sep 9, 2024
1 parent f1363ce commit c4061a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;

import io.github.bakedlibs.dough.common.CommonPatterns;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.JsonUtils;

/**
* This Class represents a Metrics Service that sends data to https://bstats.org/
Expand Down Expand Up @@ -204,7 +204,7 @@ private int getLatestVersion() {
return -1;
}

JsonElement element = JsonParser.parseString(response.body());
JsonElement element = JsonUtils.parseString(response.body());

return element.getAsJsonObject().get("tag_name").getAsInt();
} catch (IOException | InterruptedException | JsonParseException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;

import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import io.github.thebusybiscuit.slimefun4.utils.JsonUtils;

/**
* The {@link GitHubConnector} is used to connect to the GitHub API service.
Expand Down Expand Up @@ -120,7 +120,7 @@ void download() {
HttpRequest.newBuilder(uri).header("User-Agent", USER_AGENT).build(),
HttpResponse.BodyHandlers.ofString()
);
JsonElement element = JsonParser.parseString(response.body());
JsonElement element = JsonUtils.parseString(response.body());

if (response.statusCode() >= 200 && response.statusCode() < 300) {
onSuccess(element);
Expand Down Expand Up @@ -162,7 +162,7 @@ void download() {
@Nullable
private JsonElement readCacheFile() {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
return JsonParser.parseString(reader.readLine());
return JsonUtils.parseString(reader.readLine());
} catch (IOException | JsonParseException e) {
Slimefun.logger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] { file.getName(), e.getClass().getSimpleName(), e.getMessage() });
return null;
Expand Down

0 comments on commit c4061a1

Please sign in to comment.