From 6953187caca1add217835ed72e23f0c8d4254526 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 16 Feb 2020 14:37:07 +0100 Subject: [PATCH] Add current + new version to update notification And fix a little typo alongside bumping versioning to v5 --- .../plotsquared/bukkit/listeners/PlayerEvents.java | 8 +++++--- .../plotsquared/bukkit/util/UpdateUtility.java | 3 ++- .../intellectualsites/plotsquared/plot/PlotVersion.java | 8 ++------ .../intellectualsites/plotsquared/plot/util/MainUtil.java | 2 +- build.gradle | 2 +- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 2f96628f0..66977d308 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -138,7 +138,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.UUID; -import java.util.function.Supplier; import java.util.regex.Pattern; /** @@ -152,6 +151,7 @@ import java.util.regex.Pattern; private boolean tmpTeleport = true; private Field fieldPlayer; private PlayerMoveEvent moveTmp; + private String internalVersion; private String spigotVersion; { @@ -727,15 +727,17 @@ import java.util.regex.Pattern; try { HttpsURLConnection connection = (HttpsURLConnection) new URL("https://api.spigotmc.org/legacy/update.php?resource=1177").openConnection(); connection.setRequestMethod("GET"); - this.spigotVersion = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine(); + spigotVersion = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine(); } catch (IOException e) { - PlotSquared.log(Captions.PREFIX + "&6Unable to check for updates because: " + e); + new PlotMessage(Captions.PREFIX + "Unable to check for updates, check console for further information.").color("$13"); + PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e); return; } if (!UpdateUtility.internalVersion.equals(UpdateUtility.spigotVersion)) { new PlotMessage("-----------------------------------").send(pp); new PlotMessage(Captions.PREFIX + "There appears to be a PlotSquared update available!").color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp); + new PlotMessage(Captions.PREFIX + "The latest version is " + spigotVersion).color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp); new PlotMessage(Captions.PREFIX + "https://www.spigotmc.org/resources/1177/updates").color("$1").tooltip("https://www.spigotmc.org/resources/1177/updates").send(pp); new PlotMessage("-----------------------------------").send(pp); } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/UpdateUtility.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/UpdateUtility.java index 0ea217ae1..7206fb249 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/UpdateUtility.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/UpdateUtility.java @@ -35,13 +35,14 @@ public class UpdateUtility implements Listener { connection.setRequestMethod("GET"); spigotVersion = (new BufferedReader(new InputStreamReader(connection.getInputStream()))).readLine(); } catch (IOException e) { - PlotSquared.log(Captions.PREFIX + "&6Unable to check for updates because: " + e); + PlotSquared.log(Captions.PREFIX + "&cUnable to check for updates because: " + e); this.cancel(); return; } if (!internalVersion.equals(spigotVersion)) { PlotSquared.log(Captions.PREFIX + "&6There appears to be a PlotSquared update available!"); + PlotSquared.log(Captions.PREFIX + "&6You are running version " + internalVersion + ", &6latest version is " + spigotVersion); PlotSquared.log(Captions.PREFIX + "&6https://www.spigotmc.org/resources/1177/updates"); } else { PlotSquared.log(Captions.PREFIX + "Congratulations! You are running the latest PlotSquared version."); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java index 4646a787a..ea533e598 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotVersion.java @@ -34,18 +34,14 @@ public class PlotVersion { if (hash == 0 && build == 0) { return "NoVer-SNAPSHOT"; } else { - return "4." + build; + return "5." + build; } } @Override public String toString() { if (hash == 0 && build == 0) { return "PlotSquared-NoVer-SNAPSHOT"; } else { - return "PlotSquared-4." + build; + return "PlotSquared-5." + build; } } - - public boolean isNewer(PlotVersion other) { - return other.build < this.build; - } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index 15abc1bd6..ea34c5dc9 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -67,7 +67,7 @@ public class MainUtil { public static boolean canSendChunk = false; /** * Cache of mapping x,y,z coordinates to the chunk array
- * - Used for efficent world generation
+ * - Used for efficient world generation
*/ public static short[][] x_loc; public static short[][] y_loc; diff --git a/build.gradle b/build.gradle index 63bacd9c2..f09d0d5fd 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ plugins { group = "com.github.intellectualsites.plotsquared" -def rootVersion = "4" +def rootVersion = "5" def revision = "" def buildNumber = "" def date = ""