diff options
Diffstat (limited to 'src/net/brysonsteck')
-rw-r--r-- | src/net/brysonsteck/Resurrection/Resurrection.java | 1 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java | 31 |
2 files changed, 22 insertions, 10 deletions
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; } |