Archiviert
13
0

Don't worry if we can't determine the Java version

Dieser Commit ist enthalten in:
Dan Mulloy 2017-03-18 19:29:16 -04:00
Ursprung 9289825d87
Commit aaf1af8e41
2 geänderte Dateien mit 8 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -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() {
String version = Runtime.class.getPackage().getSpecificationVersion(); try {
return (int) (Double.valueOf(version) * 10 % 10); String version = Runtime.class.getPackage().getSpecificationVersion();
return (int) (Double.parseDouble(version) * 10 % 10);
} catch (Throwable ex) {
return -1;
}
} }
} }

Datei anzeigen

@ -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 + ".");