Skip to content

Commit c4061a1

Browse files
committed
fix: fix JsonParser static methods not exist before 1.18
1 parent f1363ce commit c4061a1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030
import com.google.gson.JsonElement;
3131
import com.google.gson.JsonParseException;
32-
import com.google.gson.JsonParser;
3332

3433
import io.github.bakedlibs.dough.common.CommonPatterns;
3534
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
35+
import io.github.thebusybiscuit.slimefun4.utils.JsonUtils;
3636

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

207-
JsonElement element = JsonParser.parseString(response.body());
207+
JsonElement element = JsonUtils.parseString(response.body());
208208

209209
return element.getAsJsonObject().get("tag_name").getAsInt();
210210
} catch (IOException | InterruptedException | JsonParseException e) {

src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121

2222
import com.google.gson.JsonElement;
2323
import com.google.gson.JsonParseException;
24-
import com.google.gson.JsonParser;
2524

2625
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
26+
import io.github.thebusybiscuit.slimefun4.utils.JsonUtils;
2727

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

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

0 commit comments

Comments
 (0)