mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Make JavaVersionCheck private
This commit is contained in:
parent
62690c2a53
commit
34e02e9f3a
@ -28,11 +28,16 @@ package com.plotsquared.bukkit.util;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
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+");
|
||||||
|
|
||||||
public JavaVersionCheck() {}
|
private JavaVersionCheck() {
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkJavaVersion() {
|
public static void checkJavaVersion() {
|
||||||
final String javaVersion = System.getProperty("java.version");
|
final String javaVersion = System.getProperty("java.version");
|
||||||
@ -48,7 +53,12 @@ public class JavaVersionCheck {
|
|||||||
|
|
||||||
final int javaVersionNumber;
|
final int javaVersionNumber;
|
||||||
try {
|
try {
|
||||||
javaVersionNumber = Integer.parseInt(version);
|
Matcher versionMatcher = NUM_PATTERN.matcher(version);
|
||||||
|
if (!versionMatcher.find()) {
|
||||||
|
JavaVersionCheck.notify(javaVersion, logger);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
javaVersionNumber = Integer.parseInt(versionMatcher.group());
|
||||||
} catch (final NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
logger.error("Failed to determine Java version. Could not parse {}", version, e);
|
logger.error("Failed to determine Java version. Could not parse {}", version, e);
|
||||||
JavaVersionCheck.notify(javaVersion, logger);
|
JavaVersionCheck.notify(javaVersion, logger);
|
||||||
|
Loading…
Reference in New Issue
Block a user