Skip to content

Commit aaf1af8

Browse files
committed
Don't worry if we can't determine the Java version
1 parent 9289825 commit aaf1af8

File tree

2 files changed

+8
-4
lines changed
  • modules

2 files changed

+8
-4
lines changed

modules/API/src/main/java/com/comphenix/protocol/utility/Util.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,14 @@ public static boolean isUsingSpigot() {
6363

6464
/**
6565
* Gets the currently running major Java version.
66-
* @return The version
66+
* @return The version or -1 if it could not be found
6767
*/
6868
public static int getJavaVersion() {
69-
String version = Runtime.class.getPackage().getSpecificationVersion();
70-
return (int) (Double.valueOf(version) * 10 % 10);
69+
try {
70+
String version = Runtime.class.getPackage().getSpecificationVersion();
71+
return (int) (Double.parseDouble(version) * 10 % 10);
72+
} catch (Throwable ex) {
73+
return -1;
74+
}
7175
}
7276
}

modules/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLib.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void onLoad() {
156156
ProtocolLogger.init(this);
157157

158158
int java = Util.getJavaVersion();
159-
if (java < 8 && !getConfig().getBoolean("ignoreJava", false)) {
159+
if (java != -1 && java < 8 && !getConfig().getBoolean("ignoreJava", false)) {
160160
logger.warning("Detected outdated Java version: Java " + java);
161161
logger.warning("It is recommended that you update to Java 8 as soon as possible.");
162162
logger.warning("Future versions of ProtocolLib many not support Java " + java + ".");

0 commit comments

Comments
 (0)