mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Update java 8 notice
This commit is contained in:
parent
714837dd00
commit
3ca8a94419
@ -157,7 +157,7 @@ import java.util.concurrent.Executors;
|
|||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static com.plotsquared.bukkit.util.JavaVersionCheck.checkJavaVersion;
|
import static com.plotsquared.bukkit.util.JavaVersionCheck.checkJvm;
|
||||||
import static com.plotsquared.core.util.PremiumVerification.getDownloadID;
|
import static com.plotsquared.core.util.PremiumVerification.getDownloadID;
|
||||||
import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
||||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||||
@ -515,7 +515,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}, 100L, 100L);
|
}, 100L, 100L);
|
||||||
|
|
||||||
// Check whether the server runs on 11 or greater
|
// Check whether the server runs on 11 or greater
|
||||||
checkJavaVersion();
|
checkJvm();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unload() {
|
private void unload() {
|
||||||
|
@ -34,41 +34,39 @@ import java.util.regex.Pattern;
|
|||||||
public class JavaVersionCheck {
|
public class JavaVersionCheck {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger("P2/" + JavaVersionCheck.class.getSimpleName());
|
private static final Logger logger = LoggerFactory.getLogger("P2/" + JavaVersionCheck.class.getSimpleName());
|
||||||
private final static Pattern NUM_PATTERN = Pattern.compile("\\d+");
|
|
||||||
|
|
||||||
private JavaVersionCheck() {
|
private static int checkJavaVersion() {
|
||||||
|
String javaVersion = System.getProperty("java.version");
|
||||||
|
final Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
|
||||||
|
if (!matcher.find()) {
|
||||||
|
logger.error("Failed to determine Java version; Could not parse: {}", javaVersion);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String version = matcher.group(1);
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(version);
|
||||||
|
} catch (final NumberFormatException e) {
|
||||||
|
logger.error("Failed to determine Java version; Could not parse {} from {}", version, javaVersion, e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkJavaVersion() {
|
public static void checkJvm() {
|
||||||
final String javaVersion = System.getProperty("java.version");
|
if (checkJavaVersion() < 11) {
|
||||||
final int dotIndex = javaVersion.indexOf('.');
|
logger.error("************************************************************");
|
||||||
|
logger.error("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA.");
|
||||||
if (javaVersion.startsWith("1.")) {
|
logger.error("* PLOTSQUARED WILL STOP BEING COMPATIBLE WITH THIS VERSION OF");
|
||||||
JavaVersionCheck.notify(javaVersion, logger);
|
logger.error("* JAVA WHEN MINECRAFT 1.17 IS RELEASED.");
|
||||||
return;
|
logger.error("*");
|
||||||
|
logger.error("* Please update the version of Java to 11. When Minecraft 1.17");
|
||||||
|
logger.error("* is released, support for versions of Java prior to 11 will");
|
||||||
|
logger.error("* be dropped.");
|
||||||
|
logger.error("*");
|
||||||
|
logger.error("* Current Java version: {}", System.getProperty("java.version"));
|
||||||
|
logger.error("************************************************************");
|
||||||
}
|
}
|
||||||
|
if (checkJavaVersion() >= 15) {
|
||||||
final int endIndex = dotIndex == -1 ? javaVersion.length() : dotIndex;
|
|
||||||
final String version = javaVersion.substring(0, endIndex);
|
|
||||||
|
|
||||||
final int javaVersionNumber;
|
|
||||||
try {
|
|
||||||
Matcher versionMatcher = NUM_PATTERN.matcher(version);
|
|
||||||
if (!versionMatcher.find()) {
|
|
||||||
JavaVersionCheck.notify(javaVersion, logger);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
javaVersionNumber = Integer.parseInt(versionMatcher.group());
|
|
||||||
} catch (final NumberFormatException e) {
|
|
||||||
logger.error("Failed to determine Java version. Could not parse {}", version, e);
|
|
||||||
JavaVersionCheck.notify(javaVersion, logger);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (javaVersionNumber < 11) {
|
|
||||||
JavaVersionCheck.notify(javaVersion, logger);
|
|
||||||
}
|
|
||||||
if (javaVersionNumber >= 11) {
|
|
||||||
logger.error("************************************************************");
|
logger.error("************************************************************");
|
||||||
logger.error("* PlotSquared uses Nashorn for the internal scripting engine.");
|
logger.error("* PlotSquared uses Nashorn for the internal scripting engine.");
|
||||||
logger.error("* Within Java 15, Nashorn has been removed from Java.");
|
logger.error("* Within Java 15, Nashorn has been removed from Java.");
|
||||||
@ -77,16 +75,4 @@ public class JavaVersionCheck {
|
|||||||
logger.error("************************************************************");
|
logger.error("************************************************************");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notify(final String version, final Logger logger) {
|
|
||||||
logger.error("************************************************************");
|
|
||||||
logger.error("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA.");
|
|
||||||
logger.error("* PLOTSQUARED WILL STOP BEING COMPATIBLE WITH THIS VERSION OF");
|
|
||||||
logger.error("* JAVA WHEN MINECRAFT 1.17 IS RELEASED.");
|
|
||||||
logger.error("*");
|
|
||||||
logger.error("* Please update the version of Java to 11.");
|
|
||||||
logger.error("*");
|
|
||||||
logger.error("* Current Java version: " + version);
|
|
||||||
logger.error("************************************************************");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user