diff options
author | Bryson Steck <steck.bryson@gmail.com> | 2021-06-06 17:17:52 -0600 |
---|---|---|
committer | Bryson Steck <steck.bryson@gmail.com> | 2021-06-06 17:17:52 -0600 |
commit | ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04 (patch) | |
tree | cbc6854f5da9c7b48c3833c7d8344d08dc5ab470 | |
parent | f90b81e427743be22ba89a1f74a3931e424b26ba (diff) | |
download | resurrection-ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04.tar resurrection-ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04.tar.gz resurrection-ab4b6ee6887aef3d6222c150d1ca56f2b55fbe04.tar.bz2 |
added updater, checking if it works...
-rw-r--r-- | lib/gson-2.8.7.jar | bin | 0 -> 240400 bytes | |||
-rw-r--r-- | out/artifacts/Resurrection_jar/Resurrection.jar | bin | 1334242 -> 1335478 bytes | |||
-rw-r--r-- | out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class | bin | 1516 -> 3062 bytes | |||
-rw-r--r-- | out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class | bin | 341 -> 1985 bytes | |||
-rw-r--r-- | src/net/brysonsteck/Resurrection/Resurrection.java | 19 | ||||
-rw-r--r-- | src/net/brysonsteck/Resurrection/startup/CheckForUpdate.java | 39 |
6 files changed, 57 insertions, 1 deletions
diff --git a/lib/gson-2.8.7.jar b/lib/gson-2.8.7.jar Binary files differnew file mode 100644 index 0000000..215e823 --- /dev/null +++ b/lib/gson-2.8.7.jar diff --git a/out/artifacts/Resurrection_jar/Resurrection.jar b/out/artifacts/Resurrection_jar/Resurrection.jar Binary files differindex d8442f8..371e6ba 100644 --- a/out/artifacts/Resurrection_jar/Resurrection.jar +++ b/out/artifacts/Resurrection_jar/Resurrection.jar diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class Binary files differindex 717c5cd..8e0e0c2 100644 --- a/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class +++ b/out/production/Resurrection/net/brysonsteck/Resurrection/Resurrection.class diff --git a/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class b/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class Binary files differindex 96d4d83..d872217 100644 --- a/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class +++ b/out/production/Resurrection/net/brysonsteck/Resurrection/startup/CheckForUpdate.class diff --git a/src/net/brysonsteck/Resurrection/Resurrection.java b/src/net/brysonsteck/Resurrection/Resurrection.java index bfd8363..00c5568 100644 --- a/src/net/brysonsteck/Resurrection/Resurrection.java +++ b/src/net/brysonsteck/Resurrection/Resurrection.java @@ -2,8 +2,10 @@ package net.brysonsteck.Resurrection; import net.brysonsteck.Resurrection.commands.CommandAbout; import net.brysonsteck.Resurrection.commands.CommandResurrect; +import net.brysonsteck.Resurrection.startup.CheckForUpdate; import org.bukkit.command.CommandExecutor; import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; public class Resurrection extends JavaPlugin { @@ -18,6 +20,20 @@ public class Resurrection extends JavaPlugin { @Override public void onEnable() { super.onEnable(); + PluginDescriptionFile pluginInfo = getDescription(); + + // check for updates + System.out.println("[Resurrection] Checking for updates..."); + CheckForUpdate check = new CheckForUpdate(); + String newestVersion = check.getVersion(); + String newestVersionURL = check.getVersionURL(); + if (pluginInfo.getVersion().equals(newestVersion)) { + System.out.println("[Resurrection] " + newestVersion + " is the latest version of Resurrection."); + } else { + System.out.println("[Resurrection] A new version of Resurrection is available! (current: " + pluginInfo.getVersion() + ", newest: " + newestVersion); + System.out.println("[Resurrection] You can download the latest release on GitHub here \\/"); + System.out.println("[Resurrection] " + newestVersionURL); + } // register listener this.getServer().getPluginManager().registerEvents(new PlayerListener(), this); @@ -26,11 +42,12 @@ public class Resurrection extends JavaPlugin { this.getCommand("about").setExecutor(new CommandAbout()); this.getCommand("resurrect").setExecutor(new CommandResurrect()); - System.out.println("[Resurrection] I'm alive!"); + System.out.println("[Resurrection] Successfully Started."); } // 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 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; + } } |