Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci skip] fix: fix JsonParser static methods not exist before 1.18 #4238

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading