Java version warning

This commit is contained in:
IzzelAliz 2021-05-12 23:15:02 +08:00
parent 32d233f8f2
commit b2b9a08824
7 changed files with 63 additions and 13 deletions

View File

@ -23,15 +23,19 @@ import java.util.jar.Manifest;
public abstract class ArclightMain {
private static final int MIN_DEPRECATED_VERSION = 60;
private static final int MIN_DEPRECATED_JAVA_VERSION = 16;
public void run(String[] args) throws Throwable {
System.setProperty("java.util.logging.manager", ArclightLazyLogManager.class.getCanonicalName());
System.setProperty("log4j.jul.LoggerAdapter", "io.izzel.arclight.common.mod.util.log.ArclightLoggerAdapter");
ArclightLocale.info("i18n.using-language", ArclightConfig.spec().getLocale().getCurrent(), ArclightConfig.spec().getLocale().getFallback());
this.afterSetup();
try { // Java 9 & Java 兼容性
try {
int javaVersion = (int) Float.parseFloat(System.getProperty("java.class.version"));
if (javaVersion == 53) {
throw new Exception("Only Java 8 and Java 10+ is supported.");
if (javaVersion < MIN_DEPRECATED_VERSION) {
ArclightLocale.error("java.deprecated", System.getProperty("java.version"), MIN_DEPRECATED_JAVA_VERSION);
Thread.sleep(3000);
}
Unsafe.ensureClassInitialized(EnumHelper.class);
} catch (Throwable t) {

View File

@ -30,6 +30,15 @@ arclight {
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
sourceSets {
applaunch {
java {
compileClasspath += main.output
runtimeClasspath += main.output
}
}
}
configurations {
embed
implementation.extendsFrom(embed)
@ -97,7 +106,7 @@ processResources {
jar {
manifest.attributes 'MixinConnector': 'io.izzel.arclight.impl.ArclightConnector_1_16'
manifest.attributes 'Main-Class': 'io.izzel.arclight.server.Main_1_16'
manifest.attributes 'Main-Class': 'io.izzel.arclight.server.Launcher'
manifest.attributes 'Implementation-Title': 'Arclight'
manifest.attributes 'Implementation-Version': "arclight-$minecraftVersion-${project.version}-${getGitHash()}"
manifest.attributes 'Implementation-Vendor': 'Arclight Team'
@ -112,6 +121,7 @@ jar {
exclude "LICENSE.txt"
}
from(project(':arclight-common').tasks.jar.outputs.files.collect { it.isDirectory() ? it : zipTree(it) })
from sourceSets.applaunch.output.classesDirs
}
remapSpigotJar {
@ -128,6 +138,10 @@ compileJava {
options.encoding = 'UTF-8'
}
compileApplaunchJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_6
}
task srgJar(type: Jar) {
from(tasks.jar.outputs.files.collect { it.isDirectory() ? it : zipTree(it) }) {
include 'io/izzel/**'

View File

@ -0,0 +1,18 @@
package io.izzel.arclight.server;
public class Launcher {
private static final int MIN_CLASS_VERSION = 52;
private static final int MIN_JAVA_VERSION = 8;
public static void main(String[] args) throws Throwable {
int javaVersion = (int) Float.parseFloat(System.getProperty("java.class.version"));
if (javaVersion < MIN_CLASS_VERSION) {
System.err.println("Arclight requires Java " + MIN_JAVA_VERSION);
System.err.println("Current: " + System.getProperty("java.version"));
System.exit(-1);
return;
}
Main_1_16.main(args);
}
}

View File

@ -4,15 +4,15 @@ import io.izzel.arclight.api.ArclightVersion;
import io.izzel.arclight.common.ArclightMain;
import io.izzel.arclight.forgeinstaller.ForgeInstaller;
public class Main_1_16 extends ArclightMain {
public class Main_1_16 {
public static void main(String[] args) throws Throwable {
new Main_1_16().run(args);
}
new ArclightMain() {
@Override
protected void afterSetup() throws Throwable {
ArclightVersion.setVersion(ArclightVersion.v1_16_4);
ForgeInstaller.install();
}
}.run(args);
}
}

View File

@ -1,6 +1,6 @@
allprojects {
group 'io.izzel.arclight'
version '1.0.18'
version '1.0.19-SNAPSHOT'
ext {
agpVersion = '1.15'

View File

@ -28,6 +28,13 @@ downloader {
forge-install = "Forge installation is starting, please wait... "
access-denied = "Access denied for file {0}: {1}"
}
java {
deprecated = [
"You are running an outdated Java version"
"Current {0} Recommended {1}"
"Current Java will not be supported in future"
]
}
implementer {
not-found = "Class not found {}"

View File

@ -28,6 +28,13 @@ downloader {
forge-install = "即将开始 Forge 安装,请等待一段时间"
access-denied = "没有对 {0} 操作的权限: {1}"
}
java {
deprecated = [
"您正在使用过时的 Java 版本"
"当前版本 {0} 推荐使用 {1}"
"该版本的 Java 未来将不受支持"
]
}
implementer {
not-found = "找不到类 {}"