aboutsummaryrefslogtreecommitdiff
path: root/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2021-06-06 17:17:52 -0600
committerBryson Steck <steck.bryson@gmail.com>2021-06-06 17:17:52 -0600
commitab4b6ee6887aef3d6222c150d1ca56f2b55fbe04 (patch)
treecbc6854f5da9c7b48c3833c7d8344d08dc5ab470 /src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
parentf90b81e427743be22ba89a1f74a3931e424b26ba (diff)
downloadresurrection-ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04.tar
resurrection-ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04.tar.gz
resurrection-ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04.tar.bz2
added updater, checking if it works...
Diffstat (limited to 'src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java')
-rw-r--r--src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
index 2dfbf76..30e1cb1 100644
--- a/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
+++ b/src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java
@@ -1,4 +1,43 @@
package net.brysonsteck.Resurrection.startup;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+
public class CheckForUpdate {
+ String version;
+ String versionURL;
+
+ public CheckForUpdate() {
+ try {
+ URL url = new URL("resurrect.brysonsteck.net");
+ URLConnection request = url.openConnection();
+ request.connect();
+ JsonParser json = new JsonParser();
+ JsonElement root = json.parse(new InputStreamReader((InputStream) request.getContent()));
+ JsonObject rootobj = root.getAsJsonObject();
+ version = rootobj.get("current-version").getAsString();
+ versionURL = rootobj.get("release-url").getAsString();
+ } catch (IOException e) {
+ System.out.println("[Resurrection] An error has occurred while attempting to check for updates.");
+ e.printStackTrace();
+ }
+ }
+
+ public String getVersionURL() {
+ return versionURL;
+ }
+
+ public String getVersion() {
+ return version;
+ }
}