From 65033eee492e0016f88de2d765701bdb854ce330 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Sun, 6 Jun 2021 17:44:10 -0600 Subject: updater should work now --- out/artifacts/Resurrection_jar/Resurrection.jar | Bin 1335484 -> 1335744 bytes .../brysonsteck/Resurrection/Resurrection.class | Bin 3062 -> 3062 bytes .../Resurrection/startup/CheckForUpdate.class | Bin 1992 -> 2439 bytes src/net/brysonsteck/Resurrection/Resurrection.java | 1 - .../Resurrection/startup/CheckForUpdate.java | 31 +++++++++++++++------ 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/out/artifacts/Resurrection_jar/Resurrection.jar b/out/artifacts/Resurrection_jar/Resurrection.jar index bbb9fdf..2892ee1 100644 Binary files a/out/artifacts/Resurrection_jar/Resurrection.jar and b/out/artifacts/Resurrection_jar/Resurrection.jar differ diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class index 8e0e0c2..4bbc08a 100644 Binary files a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class and b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class differ diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class b/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class index 6b3fa72..a9eda0b 100644 Binary files a/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class and b/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class differ diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index 00c5568..33c5b99 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -47,7 +47,6 @@ public class Resurrection extends JavaPlugin { // end of spigot things public static void main(String[] args) { - // PlayerData playerData = new PlayerData(); // playerData.saveData("This is the first line\nthis is the second line"); // System.out.println(playerData.getPlayers()); diff --git a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java index 8a13780..1507480 100644 --- a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java +++ b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java @@ -3,11 +3,9 @@ package net.brysonsteck.Resurrection.startup; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.google.gson.stream.JsonReader; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.*; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -19,11 +17,8 @@ public class CheckForUpdate { public CheckForUpdate() { try { - URL url = new URL("http://resurrect.brysonsteck.net"); - URLConnection request = url.openConnection(); - request.connect(); - JsonParser json = new JsonParser(); - JsonElement root = json.parse(new InputStreamReader((InputStream) request.getContent())); + String json = urlReader(); + JsonElement root = new JsonParser().parse(json); JsonObject rootobj = root.getAsJsonObject(); version = rootobj.get("current-version").getAsString(); versionURL = rootobj.get("release-url").getAsString(); @@ -33,6 +28,24 @@ public class CheckForUpdate { } } + public String urlReader() throws IOException { + URL website = new URL("https://brysonsteck.net/resurrect.json"); + URLConnection connection = website.openConnection(); + BufferedReader in = new BufferedReader( + new InputStreamReader( + connection.getInputStream())); + + StringBuilder response = new StringBuilder(); + String inputLine; + + while ((inputLine = in.readLine()) != null) + response.append(inputLine); + + in.close(); + + return response.toString(); + } + public String getVersionURL() { return versionURL; } -- cgit v1.2.3