From b135bf86c308a9287dca73b14e036dc4a9bedc9c Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sun, 9 Dec 2012 17:09:24 +0100 Subject: [PATCH] Add the ability to skip the version check for a specific MC version. --- .../java/com/comphenix/protocol/MinecraftVersion.java | 10 +++++++++- .../java/com/comphenix/protocol/ProtocolLibrary.java | 4 ++-- ProtocolLib/src/main/resources/config.yml | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/MinecraftVersion.java b/ProtocolLib/src/main/java/com/comphenix/protocol/MinecraftVersion.java index 78ff9e0c..6544ac11 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/MinecraftVersion.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/MinecraftVersion.java @@ -93,6 +93,14 @@ class MinecraftVersion implements Comparable { return build; } + /** + * Retrieve the version String (major.minor.build) only. + * @return A normal version string. + */ + public String getVersion() { + return String.format("%s.%s.%s", major, minor, build); + } + @Override public int compareTo(MinecraftVersion o) { if (o == null) @@ -131,7 +139,7 @@ class MinecraftVersion implements Comparable { @Override public String toString() { // Convert to a String that we can parse back again - return String.format("(MC: %s.%s.%s)", major, minor, build); + return String.format("(MC: %s)", getVersion()); } /** diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index 2d753368..f0563828 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -235,9 +235,9 @@ public class ProtocolLibrary extends JavaPlugin { MinecraftVersion minimum = new MinecraftVersion(MINIMUM_MINECRAFT_VERSION); MinecraftVersion maximum = new MinecraftVersion(MAXIMUM_MINECRAFT_VERSION); MinecraftVersion current = new MinecraftVersion(getServer()); - + // Skip certain versions - if (!config.getIgnoreVersionCheck().equals(current.toString())) { + if (!config.getIgnoreVersionCheck().equals(current.getVersion())) { // We'll just warn the user for now if (current.compareTo(minimum) < 0) logger.warning("Version " + current + " is lower than the minimum " + minimum); diff --git a/ProtocolLib/src/main/resources/config.yml b/ProtocolLib/src/main/resources/config.yml index 15828ee1..0b5a4f64 100644 --- a/ProtocolLib/src/main/resources/config.yml +++ b/ProtocolLib/src/main/resources/config.yml @@ -12,4 +12,7 @@ global: metrics: true # Automatically compile structure modifiers - background compiler: true \ No newline at end of file + background compiler: true + + # Disable version checking for the given Minecraft version. Backup your world first! + ignore version check: \ No newline at end of file