mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 03:25:29 +01:00
Don't worry if we can't determine the Java version
This commit is contained in:
parent
9289825d87
commit
aaf1af8e41
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 + ".");
|
||||
|
Loading…
Reference in New Issue
Block a user