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

View File

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

View File

@ -67,7 +67,7 @@ public class MainUtil {
public static boolean canSendChunk = false;
/**
* Cache of mapping x,y,z coordinates to the chunk array<br>
* - Used for efficent world generation<br>
* - Used for efficient world generation<br>
*/
public static short[][] x_loc;
public static short[][] y_loc;

View File

@ -24,7 +24,7 @@ plugins {
group = "com.github.intellectualsites.plotsquared"
def rootVersion = "4"
def rootVersion = "5"
def revision = ""
def buildNumber = ""
def date = ""