mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 01:55:47 +01:00
Add Java version warning
We will update the required Java version at some point, the only question is when.
This commit is contained in:
parent
d89f916546
commit
38b3f40f7d
@ -121,7 +121,6 @@ public class BukkitViaLoader implements ViaPlatformLoader {
|
||||
|| Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("taco")
|
||||
|| Bukkit.getVersion().toLowerCase(Locale.ROOT).contains("torch"))
|
||||
&& serverProtocolVersion < ProtocolVersion.v1_12.getVersion()) {
|
||||
plugin.getLogger().info("Enabling Paper/TacoSpigot/Torch patch: Fixes block placement.");
|
||||
storeListener(new PaperPatch(plugin)).register();
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ViaManagerImpl implements ViaManager {
|
||||
private final ProtocolManagerImpl protocolManager = new ProtocolManagerImpl();
|
||||
@ -140,6 +142,8 @@ public class ViaManagerImpl implements ViaManager {
|
||||
}
|
||||
}
|
||||
|
||||
checkJavaVersion();
|
||||
|
||||
// Check for unsupported plugins/software
|
||||
unsupportedSoftwareWarning();
|
||||
|
||||
@ -204,7 +208,31 @@ public class ViaManagerImpl implements ViaManager {
|
||||
loader.unload();
|
||||
}
|
||||
|
||||
private void unsupportedSoftwareWarning() {
|
||||
private final void checkJavaVersion() { // Stolen from Paper
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
|
||||
if (!matcher.find()) {
|
||||
platform.getLogger().warning("Failed to determine Java version; could not parse: " + javaVersion);
|
||||
return;
|
||||
}
|
||||
|
||||
String versionString = matcher.group(1);
|
||||
int version;
|
||||
try {
|
||||
version = Integer.parseInt(versionString);
|
||||
} catch (NumberFormatException e) {
|
||||
platform.getLogger().warning("Failed to determine Java version; could not parse: " + versionString);
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (version < 16) {
|
||||
platform.getLogger().warning("You are running an outdated Java version, please consider updating it to at least Java 16 (your version is " + javaVersion + "). "
|
||||
+ "At some point in the future, ViaVersion will no longer be compatible with this version of Java.");
|
||||
}
|
||||
}
|
||||
|
||||
private final void unsupportedSoftwareWarning() {
|
||||
boolean found = false;
|
||||
for (UnsupportedSoftware software : platform.getUnsupportedSoftwareClasses()) {
|
||||
if (!software.findMatch()) {
|
||||
|
Loading…
Reference in New Issue
Block a user