From c2abc4277b928d26ab6ed94b3d36b4ac296bc224 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sun, 6 Oct 2013 02:31:55 +0200 Subject: [PATCH] Fix a critial bug that prevents PB from loading. This was caused by a previous patch that corrected the version parser for special Spigot versions with a snapshot protocol enabled. Unfortunately, this also causes the comparer to fail on normal version ... Somehow, that got through testing. --- .../com/comphenix/protocol/ProtocolLibrary.java | 16 +++++++++------- .../protocol/utility/MinecraftVersion.java | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index f32516eb..a61db9b7 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -71,7 +71,7 @@ public class ProtocolLibrary extends JavaPlugin { public static final ReportType REPORT_METRICS_IO_ERROR = new ReportType("Unable to enable metrics due to network problems."); public static final ReportType REPORT_METRICS_GENERIC_ERROR = new ReportType("Unable to enable metrics due to network problems."); - public static final ReportType REPORT_CANNOT_PARSE_MINECRAFT_VERSION = new ReportType("Unable to retrieve current Minecraft version."); + public static final ReportType REPORT_CANNOT_PARSE_MINECRAFT_VERSION = new ReportType("Unable to retrieve current Minecraft version. Assuming %s"); public static final ReportType REPORT_CANNOT_DETECT_CONFLICTING_PLUGINS = new ReportType("Unable to detect conflicting plugin versions."); public static final ReportType REPORT_CANNOT_REGISTER_COMMAND = new ReportType("Cannot register command %s: %s"); @@ -367,9 +367,10 @@ public class ProtocolLibrary extends JavaPlugin { // Used to check Minecraft version private MinecraftVersion verifyMinecraftVersion() { + MinecraftVersion minimum = new MinecraftVersion(MINIMUM_MINECRAFT_VERSION); + MinecraftVersion maximum = new MinecraftVersion(MAXIMUM_MINECRAFT_VERSION); + try { - MinecraftVersion minimum = new MinecraftVersion(MINIMUM_MINECRAFT_VERSION); - MinecraftVersion maximum = new MinecraftVersion(MAXIMUM_MINECRAFT_VERSION); MinecraftVersion current = new MinecraftVersion(getServer()); // Skip certain versions @@ -383,11 +384,12 @@ public class ProtocolLibrary extends JavaPlugin { return current; } catch (Exception e) { - reporter.reportWarning(this, Report.newBuilder(REPORT_CANNOT_PARSE_MINECRAFT_VERSION).error(e)); + reporter.reportWarning(this, + Report.newBuilder(REPORT_CANNOT_PARSE_MINECRAFT_VERSION).error(e).messageParam(maximum)); + + // Unknown version - just assume it is the latest + return maximum; } - - // Unknown version - return null; } private void checkConflictingVersions() { diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java index d8a07dd4..5f9ccc28 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java @@ -218,7 +218,7 @@ public class MinecraftVersion implements Comparable { compare(getBuild(), o.getBuild()). // No development String means it's a release compare(getDevelopmentStage(), o.getDevelopmentStage(), Ordering.natural().nullsLast()). - compare(getSnapshot(), o.getSnapshot()). + compare(getSnapshot(), o.getSnapshot(), Ordering.natural().nullsFirst()). result(); }