Rewrite what compares layered versions

This commit is contained in:
ME1312 2018-03-14 17:50:15 -04:00
parent bb7cfa9e57
commit 12a74b3474
24 changed files with 122 additions and 374 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -125,17 +125,6 @@ public class Version implements Serializable, Comparable<Version> {
this.string = string;
}
/*
* The internal toString() method
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
* 5 1.0.0 0 7
*/
private String toInternalString() {
String str = type.id + ' ' + string;
if (parent != null) str = parent.toInternalString()+' '+str;
return str;
}
/**
* The default toString() method<br>
* <br>
@ -223,14 +212,27 @@ public class Version implements Serializable, Comparable<Version> {
* @param version The version to compare to
*/
public int compareTo(Version version) {
String version1 = toInternalString();
String version2 = version.toInternalString();
// Compare parent versions first
if (this.parent != null || version.parent != null) {
int parent = ((this.parent == null)?this:this.parent).compareTo((version.parent == null)?version:version.parent);
if (parent != 0) return parent;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
if (this.parent != null && version.parent == null) {
// Version one has a parent version and version two does not, making version two the official version
return -1;
}
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
if (this.parent == null && version.parent != null) {
// Version one does not have a parent version and version two does, making version one the official version
return 1;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(string);
VersionTokenizer tokenizer2 = new VersionTokenizer(version.string);
int number1, number2;
String suffix1, suffix2;
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
@ -313,71 +315,6 @@ public class Version implements Serializable, Comparable<Version> {
* @param ver2 Version to Compare
*/
public static int compare(Version ver1, Version ver2) {
String version1 = ver1.toInternalString();
String version2 = ver2.toInternalString();
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
do {
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
if (number1 != 0 || suffix1.length() != 0) {
// Version one is longer than number two, and non-zero
return 1;
}
}
while (tokenizer1.MoveNext());
// Version one is longer than version two, but zero
return 0;
}
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number1 < number2) {
// Number one is less than number two
return -1;
}
if (number1 > number2) {
// Number one is greater than number two
return 1;
}
boolean empty1 = suffix1.length() == 0;
boolean empty2 = suffix2.length() == 0;
if (empty1 && empty2) continue; // No suffixes
if (empty1) return 1; // First suffix is empty (1.2 > 1.2b)
if (empty2) return -1; // Second suffix is empty (1.2a < 1.2)
// Lexical comparison of suffixes
int result = suffix1.compareTo(suffix2);
if (result != 0) return result;
}
if (tokenizer2.MoveNext()) {
do {
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number2 != 0 || suffix2.length() != 0) {
// Version one is longer than version two, and non-zero
return -1;
}
}
while (tokenizer2.MoveNext());
// Version two is longer than version one, but zero
return 0;
}
return 0;
return ver1.compareTo(ver2);
}
}

View File

@ -73,17 +73,17 @@ public final class SubCommand extends CommandX {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = plugin.version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(plugin.version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (updversion.equals(plugin.version)) {
if (updcount == 0) {
sender.sendMessage("You are on the latest version.");
} else {
sender.sendMessage("You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");

View File

@ -498,17 +498,17 @@ public final class SubPlugin extends BungeeCord implements Listener {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (!updversion.equals(version)) System.out.println("SubServers > SubServers.Bungee v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
if (updcount > 0) System.out.println("SubServers > SubServers.Bungee v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
} catch (Exception e) {}
}
}, 0, TimeUnit.DAYS.toMillis(2));

Binary file not shown.

View File

@ -125,17 +125,6 @@ public class Version implements Serializable, Comparable<Version> {
this.string = string;
}
/*
* The internal toString() method
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
* 5 1.0.0 0 7
*/
private String toInternalString() {
String str = type.id + ' ' + string;
if (parent != null) str = parent.toInternalString()+' '+str;
return str;
}
/**
* The default toString() method<br>
* <br>
@ -144,12 +133,12 @@ public class Version implements Serializable, Comparable<Version> {
*
* @return Version as a String
*/
@Override
public String toString() {
@Override
public String toString() {
String str = (parent == null)?"":parent.toString()+'/'+type.shortname;
str += string;
return str;
}
}
/**
* The full toString() method<br>
@ -193,7 +182,7 @@ public class Version implements Serializable, Comparable<Version> {
return str;
}
@Override
@Override
public boolean equals(Object object) {
if (object instanceof Version) {
return equals((Version) object);
@ -211,11 +200,11 @@ public class Version implements Serializable, Comparable<Version> {
public boolean equals(Version version) {
return compareTo(version) == 0;
}
/*
* Returns 1 if Greater than
* Returns 0 if Equal
* Returns -1 if Less than
* Returns -1 if Less than
*//**
*
* Compare Versions
@ -223,14 +212,27 @@ public class Version implements Serializable, Comparable<Version> {
* @param version The version to compare to
*/
public int compareTo(Version version) {
String version1 = toInternalString();
String version2 = version.toInternalString();
// Compare parent versions first
if (this.parent != null || version.parent != null) {
int parent = ((this.parent == null)?this:this.parent).compareTo((version.parent == null)?version:version.parent);
if (parent != 0) return parent;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
if (this.parent != null && version.parent == null) {
// Version one has a parent version and version two does not, making version two the official version
return -1;
}
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
if (this.parent == null && version.parent != null) {
// Version one does not have a parent version and version two does, making version one the official version
return 1;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(string);
VersionTokenizer tokenizer2 = new VersionTokenizer(version.string);
int number1, number2;
String suffix1, suffix2;
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
@ -313,71 +315,6 @@ public class Version implements Serializable, Comparable<Version> {
* @param ver2 Version to Compare
*/
public static int compare(Version ver1, Version ver2) {
String version1 = ver1.toInternalString();
String version2 = ver2.toInternalString();
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
do {
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
if (number1 != 0 || suffix1.length() != 0) {
// Version one is longer than number two, and non-zero
return 1;
}
}
while (tokenizer1.MoveNext());
// Version one is longer than version two, but zero
return 0;
}
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number1 < number2) {
// Number one is less than number two
return -1;
}
if (number1 > number2) {
// Number one is greater than number two
return 1;
}
boolean empty1 = suffix1.length() == 0;
boolean empty2 = suffix2.length() == 0;
if (empty1 && empty2) continue; // No suffixes
if (empty1) return 1; // First suffix is empty (1.2 > 1.2b)
if (empty2) return -1; // Second suffix is empty (1.2a < 1.2)
// Lexical comparison of suffixes
int result = suffix1.compareTo(suffix2);
if (result != 0) return result;
}
if (tokenizer2.MoveNext()) {
do {
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number2 != 0 || suffix2.length() != 0) {
// Version one is longer than version two, and non-zero
return -1;
}
}
while (tokenizer2.MoveNext());
// Version two is longer than version one, but zero
return 0;
}
return 0;
return ver1.compareTo(ver2);
}
}

View File

@ -55,17 +55,17 @@ public final class SubCommand implements CommandExecutor {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = plugin.version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(plugin.version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (updversion.equals(plugin.version)) {
if (updcount == 0) {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Version.Latest"));
} else {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Version.Outdated").replace("$int$", Integer.toString(updcount)));

View File

@ -94,17 +94,17 @@ public final class SubPlugin extends JavaPlugin {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (!updversion.equals(version)) System.out.println("SubServers > SubServers.Client.Bukkit v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
if (updcount > 0) System.out.println("SubServers > SubServers.Client.Bukkit v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
} catch (Exception e) {}
}, 0, TimeUnit.DAYS.toSeconds(2) * 20);
} catch (IOException e) {

Binary file not shown.

View File

@ -387,17 +387,17 @@ public final class ExHost {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (!updversion.equals(version)) log.info.println("SubServers.Host v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
if (updcount > 0) log.info.println("SubServers.Host v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
} catch (Exception e) {}
}
}, 0, TimeUnit.DAYS.toMillis(2));

View File

@ -125,17 +125,6 @@ public class Version implements Serializable, Comparable<Version> {
this.string = string;
}
/*
* The internal toString() method
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
* 5 1.0.0 0 7
*/
private String toInternalString() {
String str = type.id + ' ' + string;
if (parent != null) str = parent.toInternalString()+' '+str;
return str;
}
/**
* The default toString() method<br>
* <br>
@ -144,12 +133,12 @@ public class Version implements Serializable, Comparable<Version> {
*
* @return Version as a String
*/
@Override
public String toString() {
@Override
public String toString() {
String str = (parent == null)?"":parent.toString()+'/'+type.shortname;
str += string;
return str;
}
}
/**
* The full toString() method<br>
@ -193,7 +182,7 @@ public class Version implements Serializable, Comparable<Version> {
return str;
}
@Override
@Override
public boolean equals(Object object) {
if (object instanceof Version) {
return equals((Version) object);
@ -211,11 +200,11 @@ public class Version implements Serializable, Comparable<Version> {
public boolean equals(Version version) {
return compareTo(version) == 0;
}
/*
* Returns 1 if Greater than
* Returns 0 if Equal
* Returns -1 if Less than
* Returns -1 if Less than
*//**
*
* Compare Versions
@ -223,14 +212,27 @@ public class Version implements Serializable, Comparable<Version> {
* @param version The version to compare to
*/
public int compareTo(Version version) {
String version1 = toInternalString();
String version2 = version.toInternalString();
// Compare parent versions first
if (this.parent != null || version.parent != null) {
int parent = ((this.parent == null)?this:this.parent).compareTo((version.parent == null)?version:version.parent);
if (parent != 0) return parent;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
if (this.parent != null && version.parent == null) {
// Version one has a parent version and version two does not, making version two the official version
return -1;
}
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
if (this.parent == null && version.parent != null) {
// Version one does not have a parent version and version two does, making version one the official version
return 1;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(string);
VersionTokenizer tokenizer2 = new VersionTokenizer(version.string);
int number1, number2;
String suffix1, suffix2;
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
@ -313,71 +315,6 @@ public class Version implements Serializable, Comparable<Version> {
* @param ver2 Version to Compare
*/
public static int compare(Version ver1, Version ver2) {
String version1 = ver1.toInternalString();
String version2 = ver2.toInternalString();
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
do {
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
if (number1 != 0 || suffix1.length() != 0) {
// Version one is longer than number two, and non-zero
return 1;
}
}
while (tokenizer1.MoveNext());
// Version one is longer than version two, but zero
return 0;
}
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number1 < number2) {
// Number one is less than number two
return -1;
}
if (number1 > number2) {
// Number one is greater than number two
return 1;
}
boolean empty1 = suffix1.length() == 0;
boolean empty2 = suffix2.length() == 0;
if (empty1 && empty2) continue; // No suffixes
if (empty1) return 1; // First suffix is empty (1.2 > 1.2b)
if (empty2) return -1; // Second suffix is empty (1.2a < 1.2)
// Lexical comparison of suffixes
int result = suffix1.compareTo(suffix2);
if (result != 0) return result;
}
if (tokenizer2.MoveNext()) {
do {
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number2 != 0 || suffix2.length() != 0) {
// Version one is longer than version two, and non-zero
return -1;
}
}
while (tokenizer2.MoveNext());
// Version two is longer than version one, but zero
return 0;
}
return 0;
return ver1.compareTo(ver2);
}
}

View File

@ -40,17 +40,17 @@ public class SubCommand {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = host.version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(host.version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (updversion.equals(host.version)) {
if (updcount == 0) {
host.log.message.println("You are on the latest version.");
} else {
host.log.message.println("You are " + updcount + " version" + ((updcount == 1) ? "" : "s") + " behind.");

Binary file not shown.

View File

@ -125,17 +125,6 @@ public class Version implements Serializable, Comparable<Version> {
this.string = string;
}
/*
* The internal toString() method
* new Version(new Version("1.0.0"), VersionType.PRE_ALPHA, "7") would return:
* 5 1.0.0 0 7
*/
private String toInternalString() {
String str = type.id + ' ' + string;
if (parent != null) str = parent.toInternalString()+' '+str;
return str;
}
/**
* The default toString() method<br>
* <br>
@ -144,12 +133,12 @@ public class Version implements Serializable, Comparable<Version> {
*
* @return Version as a String
*/
@Override
public String toString() {
@Override
public String toString() {
String str = (parent == null)?"":parent.toString()+'/'+type.shortname;
str += string;
return str;
}
}
/**
* The full toString() method<br>
@ -193,7 +182,7 @@ public class Version implements Serializable, Comparable<Version> {
return str;
}
@Override
@Override
public boolean equals(Object object) {
if (object instanceof Version) {
return equals((Version) object);
@ -211,11 +200,11 @@ public class Version implements Serializable, Comparable<Version> {
public boolean equals(Version version) {
return compareTo(version) == 0;
}
/*
* Returns 1 if Greater than
* Returns 0 if Equal
* Returns -1 if Less than
* Returns -1 if Less than
*//**
*
* Compare Versions
@ -223,14 +212,27 @@ public class Version implements Serializable, Comparable<Version> {
* @param version The version to compare to
*/
public int compareTo(Version version) {
String version1 = toInternalString();
String version2 = version.toInternalString();
// Compare parent versions first
if (this.parent != null || version.parent != null) {
int parent = ((this.parent == null)?this:this.parent).compareTo((version.parent == null)?version:version.parent);
if (parent != 0) return parent;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
if (this.parent != null && version.parent == null) {
// Version one has a parent version and version two does not, making version two the official version
return -1;
}
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
if (this.parent == null && version.parent != null) {
// Version one does not have a parent version and version two does, making version one the official version
return 1;
}
VersionTokenizer tokenizer1 = new VersionTokenizer(string);
VersionTokenizer tokenizer2 = new VersionTokenizer(version.string);
int number1, number2;
String suffix1, suffix2;
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
@ -313,71 +315,6 @@ public class Version implements Serializable, Comparable<Version> {
* @param ver2 Version to Compare
*/
public static int compare(Version ver1, Version ver2) {
String version1 = ver1.toInternalString();
String version2 = ver2.toInternalString();
VersionTokenizer tokenizer1 = new VersionTokenizer(version1);
VersionTokenizer tokenizer2 = new VersionTokenizer(version2);
int number1 = 0, number2 = 0;
String suffix1 = "", suffix2 = "";
while (tokenizer1.MoveNext()) {
if (!tokenizer2.MoveNext()) {
do {
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
if (number1 != 0 || suffix1.length() != 0) {
// Version one is longer than number two, and non-zero
return 1;
}
}
while (tokenizer1.MoveNext());
// Version one is longer than version two, but zero
return 0;
}
number1 = tokenizer1.getNumber();
suffix1 = tokenizer1.getSuffix();
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number1 < number2) {
// Number one is less than number two
return -1;
}
if (number1 > number2) {
// Number one is greater than number two
return 1;
}
boolean empty1 = suffix1.length() == 0;
boolean empty2 = suffix2.length() == 0;
if (empty1 && empty2) continue; // No suffixes
if (empty1) return 1; // First suffix is empty (1.2 > 1.2b)
if (empty2) return -1; // Second suffix is empty (1.2a < 1.2)
// Lexical comparison of suffixes
int result = suffix1.compareTo(suffix2);
if (result != 0) return result;
}
if (tokenizer2.MoveNext()) {
do {
number2 = tokenizer2.getNumber();
suffix2 = tokenizer2.getSuffix();
if (number2 != 0 || suffix2.length() != 0) {
// Version one is longer than version two, and non-zero
return -1;
}
}
while (tokenizer2.MoveNext());
// Version two is longer than version one, but zero
return 0;
}
return 0;
return ver1.compareTo(ver2);
}
}

View File

@ -73,17 +73,17 @@ public final class SubCommand extends CommandX {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = plugin.version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(plugin.version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (updversion.equals(plugin.version)) {
if (updcount == 0) {
sender.sendMessage("You are on the latest version.");
} else {
sender.sendMessage("You are " + updcount + " version" + ((updcount == 1) ? "" : "s") + " behind.");

View File

@ -135,17 +135,17 @@ public final class SubPlugin extends BungeeCord implements Listener {
NodeList updnodeList = updxml.getElementsByTagName("version");
Version updversion = version;
int updcount = -1;
int updcount = 0;
for (int i = 0; i < updnodeList.getLength(); i++) {
Node node = updnodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
if (!node.getTextContent().startsWith("-") && new Version(node.getTextContent()).compareTo(updversion) >= 0) {
if (!node.getTextContent().startsWith("-") && !node.getTextContent().equals(version.toString()) && new Version(node.getTextContent()).compareTo(updversion) > 0) {
updversion = new Version(node.getTextContent());
updcount++;
}
}
}
if (!updversion.equals(version)) System.out.println("SubServers > SubServers.Sync v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
if (updcount > 0) System.out.println("SubServers > SubServers.Sync v" + updversion + " is available. You are " + updcount + " version" + ((updcount == 1)?"":"s") + " behind.");
} catch (Exception e) {}
}
}, 0, TimeUnit.DAYS.toMillis(2));