1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-18 18:55:48 +00:00

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

This commit is contained in:
ybw0014 2024-09-08 17:53:32 -07:00 committed by GitHub
parent f1363ceadf
commit 17d01d74d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -29,10 +29,10 @@ import org.bukkit.plugin.Plugin;
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/
@ -204,7 +204,7 @@ public class MetricsService {
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) {

View File

@ -21,9 +21,9 @@ import javax.annotation.Nullable;
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.
@ -120,7 +120,7 @@ abstract class GitHubConnector {
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);
@ -162,7 +162,7 @@ abstract class GitHubConnector {
@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;