diff --git a/modules/API/src/main/java/com/comphenix/protocol/utility/Util.java b/modules/API/src/main/java/com/comphenix/protocol/utility/Util.java index ed36fce1..50b2e5e8 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/utility/Util.java +++ b/modules/API/src/main/java/com/comphenix/protocol/utility/Util.java @@ -63,10 +63,14 @@ public class Util { /** * Gets the currently running major Java version. - * @return The version + * @return The version or -1 if it could not be found */ public static int getJavaVersion() { - String version = Runtime.class.getPackage().getSpecificationVersion(); - return (int) (Double.valueOf(version) * 10 % 10); + try { + String version = Runtime.class.getPackage().getSpecificationVersion(); + return (int) (Double.parseDouble(version) * 10 % 10); + } catch (Throwable ex) { + return -1; + } } } diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java index b40ced09..4c2772d1 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java @@ -156,7 +156,7 @@ public class ProtocolLib extends JavaPlugin { ProtocolLogger.init(this); int java = Util.getJavaVersion(); - if (java < 8 && !getConfig().getBoolean("ignoreJava", false)) { + if (java != -1 && java < 8 && !getConfig().getBoolean("ignoreJava", false)) { logger.warning("Detected outdated Java version: Java " + java); logger.warning("It is recommended that you update to Java 8 as soon as possible."); logger.warning("Future versions of ProtocolLib many not support Java " + java + ".");