Don't worry if we can't determine the Java version
Dieser Commit ist enthalten in:
Ursprung
9289825d87
Commit
aaf1af8e41
@ -63,10 +63,14 @@ public class Util {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the currently running major Java version.
|
* 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() {
|
public static int getJavaVersion() {
|
||||||
|
try {
|
||||||
String version = Runtime.class.getPackage().getSpecificationVersion();
|
String version = Runtime.class.getPackage().getSpecificationVersion();
|
||||||
return (int) (Double.valueOf(version) * 10 % 10);
|
return (int) (Double.parseDouble(version) * 10 % 10);
|
||||||
|
} catch (Throwable ex) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ public class ProtocolLib extends JavaPlugin {
|
|||||||
ProtocolLogger.init(this);
|
ProtocolLogger.init(this);
|
||||||
|
|
||||||
int java = Util.getJavaVersion();
|
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("Detected outdated Java version: Java " + java);
|
||||||
logger.warning("It is recommended that you update to Java 8 as soon as possible.");
|
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 + ".");
|
logger.warning("Future versions of ProtocolLib many not support Java " + java + ".");
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren