aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryson Steck <steck.bryson@gmail.com>2021-06-06 17:44:10 -0600
committerBryson Steck <steck.bryson@gmail.com>2021-06-06 17:44:10 -0600
commit65033eee492e0016f88de2d765701bdb854ce330 (patch)
tree77b95693c711813d6daed3ee32d88136cf8d143f /src
parent1dade4db82b4828a8480fa379d5fb1765002b2d9 (diff)
downloadresurrection-65033eee492e0016f88de2d765701bdb854ce330.tar
resurrection-65033eee492e0016f88de2d765701bdb854ce330.tar.gz
resurrection-65033eee492e0016f88de2d765701bdb854ce330.tar.bz2
updater should work now
Diffstat (limited to 'src')
-rw-r--r--src/net/brysonsteck/Resurrection/Resurrection.java1
-rw-r--r--src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java31
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;
}