Add current + new version to update notification

And fix a little typo alongside bumping versioning to v5
This commit is contained in:
NotMyFault
2020-02-16 14:37:07 +01:00
parent 7b83f0146e
commit 6953187cac
5 changed files with 11 additions and 12 deletions

View File

@ -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);
}

View File

@ -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.");