mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-28 12:55:34 +01:00
Added separate version check for CoreProtect Edge
This commit is contained in:
parent
de978fce2c
commit
0f0c89845c
@ -1298,7 +1298,8 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
|
|
||||||
if (user.isOp() && versionAlert.get(user.getName()) == null) {
|
if (user.isOp() && versionAlert.get(user.getName()) == null) {
|
||||||
String latestVersion = NetworkHandler.latestVersion();
|
String latestVersion = NetworkHandler.latestVersion();
|
||||||
if (latestVersion != null) {
|
String latestEdgeVersion = NetworkHandler.latestEdgeVersion();
|
||||||
|
if (latestVersion != null || latestEdgeVersion != null) {
|
||||||
versionAlert.put(user.getName(), true);
|
versionAlert.put(user.getName(), true);
|
||||||
class updateAlert implements Runnable {
|
class updateAlert implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
@ -1306,8 +1307,14 @@ public class CommandHandler implements CommandExecutor {
|
|||||||
try {
|
try {
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "CoreProtect" + (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")) + Color.WHITE + " -----");
|
Chat.sendMessage(user, Color.WHITE + "----- " + Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_HEADER, "CoreProtect" + (Util.isCommunityEdition() ? " " + ConfigHandler.COMMUNITY_EDITION : "")) + Color.WHITE + " -----");
|
||||||
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "CoreProtect v" + latestVersion));
|
if (latestVersion != null) {
|
||||||
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.coreprotect.net/download/"));
|
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "CoreProtect CE v" + latestVersion));
|
||||||
|
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.coreprotect.net/download/"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.UPDATE_NOTICE, Color.WHITE, "CoreProtect v" + latestEdgeVersion));
|
||||||
|
Chat.sendMessage(user, Color.DARK_AQUA + Phrase.build(Phrase.LINK_DOWNLOAD, Color.WHITE, "www.coreprotect.net/latest/"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -42,6 +42,7 @@ public class NetworkHandler extends Language implements Runnable {
|
|||||||
private boolean background = false;
|
private boolean background = false;
|
||||||
private boolean translate = true;
|
private boolean translate = true;
|
||||||
private static String latestVersion = null;
|
private static String latestVersion = null;
|
||||||
|
private static String latestEdgeVersion = null;
|
||||||
private static String donationKey = null;
|
private static String donationKey = null;
|
||||||
|
|
||||||
public NetworkHandler(boolean startup, boolean background) {
|
public NetworkHandler(boolean startup, boolean background) {
|
||||||
@ -53,6 +54,10 @@ public class NetworkHandler extends Language implements Runnable {
|
|||||||
return latestVersion;
|
return latestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String latestEdgeVersion() {
|
||||||
|
return latestEdgeVersion;
|
||||||
|
}
|
||||||
|
|
||||||
public static String donationKey() {
|
public static String donationKey() {
|
||||||
return donationKey;
|
return donationKey;
|
||||||
}
|
}
|
||||||
@ -282,10 +287,13 @@ public class NetworkHandler extends Language implements Runnable {
|
|||||||
|
|
||||||
while (ConfigHandler.serverRunning) {
|
while (ConfigHandler.serverRunning) {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
int statusEdge = 0;
|
||||||
HttpURLConnection connection = null;
|
HttpURLConnection connection = null;
|
||||||
|
HttpURLConnection connectionEdge = null;
|
||||||
String version = Util.getPluginVersion();
|
String version = Util.getPluginVersion();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// CoreProtect Community Edition
|
||||||
URL url = new URL("http://update.coreprotect.net/version/");
|
URL url = new URL("http://update.coreprotect.net/version/");
|
||||||
connection = (HttpURLConnection) url.openConnection();
|
connection = (HttpURLConnection) url.openConnection();
|
||||||
connection.setRequestMethod("GET");
|
connection.setRequestMethod("GET");
|
||||||
@ -296,6 +304,18 @@ public class NetworkHandler extends Language implements Runnable {
|
|||||||
connection.setConnectTimeout(5000);
|
connection.setConnectTimeout(5000);
|
||||||
connection.connect();
|
connection.connect();
|
||||||
status = connection.getResponseCode();
|
status = connection.getResponseCode();
|
||||||
|
|
||||||
|
// CoreProtect Edge
|
||||||
|
url = new URL("http://update.coreprotect.net/version-edge/");
|
||||||
|
connectionEdge = (HttpURLConnection) url.openConnection();
|
||||||
|
connectionEdge.setRequestMethod("GET");
|
||||||
|
connectionEdge.setRequestProperty("Accept-Charset", "UTF-8");
|
||||||
|
connectionEdge.setRequestProperty("User-Agent", "CoreProtect/v" + version + " (by Intelli)");
|
||||||
|
connectionEdge.setDoOutput(true);
|
||||||
|
connectionEdge.setInstanceFollowRedirects(true);
|
||||||
|
connectionEdge.setConnectTimeout(5000);
|
||||||
|
connectionEdge.connect();
|
||||||
|
statusEdge = connectionEdge.getResponseCode();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// Unable to connect to update.coreprotect.net
|
// Unable to connect to update.coreprotect.net
|
||||||
@ -333,6 +353,31 @@ public class NetworkHandler extends Language implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (statusEdge == 200) {
|
||||||
|
try {
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connectionEdge.getInputStream()));
|
||||||
|
String response = reader.readLine();
|
||||||
|
|
||||||
|
if (response.length() > 0 && response.length() < 10) {
|
||||||
|
String remoteVersion = response.replaceAll("[^0-9.]", "");
|
||||||
|
if (remoteVersion.contains(".")) {
|
||||||
|
boolean newVersion = Util.newVersion(version, remoteVersion);
|
||||||
|
if (newVersion) {
|
||||||
|
latestEdgeVersion = remoteVersion;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
latestEdgeVersion = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/* Stat gathering */
|
/* Stat gathering */
|
||||||
int port = Bukkit.getServer().getPort();
|
int port = Bukkit.getServer().getPort();
|
||||||
|
Loading…
Reference in New Issue
Block a user