Fix the version check

By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
Bukkit/Spigot 2014-12-27 22:41:26 +00:00
parent 096f489fd9
commit 80cdeac288

View file

@ -185,17 +185,18 @@ public class VersionCommand extends BukkitCommand {
private void obtainVersion() { private void obtainVersion() {
String version = Bukkit.getVersion(); String version = Bukkit.getVersion();
if (version == null) version = "Custom"; if (version == null) version = "Custom";
version = "git-Spigot-5ffe41c-89ebcc2";
if (version.startsWith("git-Spigot-")) { if (version.startsWith("git-Spigot-")) {
String[] parts = version.substring("git-Spigot-".length()).split("-"); String[] parts = version.substring("git-Spigot-".length()).split("-");
int cbVersions = getDistance("craftbukkit", parts[0]); int cbVersions = getDistance("craftbukkit", parts[1]);
int spigotVersions = getDistance("spigot", parts[1]); int spigotVersions = getDistance("spigot", parts[0]);
if (cbVersions == -1 || spigotVersions == -1) { if (cbVersions == -1 || spigotVersions == -1) {
setVersionMessage("Error obtaining version information"); setVersionMessage("Error obtaining version information");
} else { } else {
if (cbVersions != 0 && spigotVersions != 0) { if (cbVersions == 0 && spigotVersions == 0) {
setVersionMessage("You are running the latest version"); setVersionMessage("You are running the latest version");
} else { } else {
setVersionMessage("You are " + (cbVersions + spigotVersions) + " behind"); setVersionMessage("You are " + (cbVersions + spigotVersions) + " version(s) behind");
} }
} }
@ -204,10 +205,10 @@ public class VersionCommand extends BukkitCommand {
if (cbVersions == -1) { if (cbVersions == -1) {
setVersionMessage("Error obtaining version information"); setVersionMessage("Error obtaining version information");
} else { } else {
if (cbVersions != 0) { if (cbVersions == 0) {
setVersionMessage("You are running the latest version"); setVersionMessage("You are running the latest version");
} else { } else {
setVersionMessage("You are " + cbVersions + " behind"); setVersionMessage("You are " + cbVersions + " version(s) behind");
} }
} }
} else { } else {