Skip to content
Merged
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
19 changes: 10 additions & 9 deletions api/src/main/java/me/tofaa/entitylib/utils/GithubUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,19 @@ private PEVersion getLatestVersion() throws IOException {
URL url = new URL("https://api.github.com/repos/" + org + "/" + repo + "/releases/latest");
URLConnection connection = url.openConnection();
connection.addRequestProperty("User-Agent", "Mozilla/5.0");
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr);
String response = reader.readLine();
JsonObject json = AdventureSerializer.getGsonSerializer().serializer().fromJson(response, JsonObject.class);

reader.close();
isr.close();
try (
InputStreamReader isr = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(isr)
) {
String response = reader.readLine();
JsonObject json = AdventureSerializer.getGsonSerializer().serializer().fromJson(response, JsonObject.class);

if (json.has("tag_name")) {
return PEVersion.fromString(json.get("tag_name").getAsString().replaceFirst("^[vV]", ""));
if (json.has("tag_name")) {
return PEVersion.fromString(json.get("tag_name").getAsString().replaceFirst("^[vV]", ""));
}
throw new IOException("Could not find name attribute in github api fetch");
}
throw new IOException("Could not find name attribute in github api fetch");
}

@Deprecated
Expand Down