diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/ArclightMain.java b/arclight-common/src/main/java/io/izzel/arclight/common/ArclightMain.java index c17f673c..e56518b0 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/ArclightMain.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/ArclightMain.java @@ -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) { diff --git a/arclight-forge-1.16/build.gradle b/arclight-forge-1.16/build.gradle index 8a1af2bc..ed952ab2 100644 --- a/arclight-forge-1.16/build.gradle +++ b/arclight-forge-1.16/build.gradle @@ -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/**' diff --git a/arclight-forge-1.16/src/applaunch/java/io/izzel/arclight/server/Launcher.java b/arclight-forge-1.16/src/applaunch/java/io/izzel/arclight/server/Launcher.java new file mode 100644 index 00000000..cb9d35c6 --- /dev/null +++ b/arclight-forge-1.16/src/applaunch/java/io/izzel/arclight/server/Launcher.java @@ -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); + } +} diff --git a/arclight-forge-1.16/src/main/java/io/izzel/arclight/server/Main_1_16.java b/arclight-forge-1.16/src/main/java/io/izzel/arclight/server/Main_1_16.java index 3982308a..f65222c2 100644 --- a/arclight-forge-1.16/src/main/java/io/izzel/arclight/server/Main_1_16.java +++ b/arclight-forge-1.16/src/main/java/io/izzel/arclight/server/Main_1_16.java @@ -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); - } - - @Override - protected void afterSetup() throws Throwable { - ArclightVersion.setVersion(ArclightVersion.v1_16_4); - ForgeInstaller.install(); + new ArclightMain() { + @Override + protected void afterSetup() throws Throwable { + ArclightVersion.setVersion(ArclightVersion.v1_16_4); + ForgeInstaller.install(); + } + }.run(args); } } diff --git a/build.gradle b/build.gradle index d152bef1..134af1a2 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ allprojects { group 'io.izzel.arclight' - version '1.0.18' + version '1.0.19-SNAPSHOT' ext { agpVersion = '1.15' diff --git a/i18n-config/src/main/resources/META-INF/i18n/en_us.conf b/i18n-config/src/main/resources/META-INF/i18n/en_us.conf index 9f29be87..1aaeb7c9 100644 --- a/i18n-config/src/main/resources/META-INF/i18n/en_us.conf +++ b/i18n-config/src/main/resources/META-INF/i18n/en_us.conf @@ -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 {}" diff --git a/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf b/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf index a08e48a8..6814d77f 100644 --- a/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf +++ b/i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf @@ -28,6 +28,13 @@ downloader { forge-install = "即将开始 Forge 安装,请等待一段时间" access-denied = "没有对 {0} 操作的权限: {1}" } +java { + deprecated = [ + "您正在使用过时的 Java 版本" + "当前版本 {0} 推荐使用 {1}" + "该版本的 Java 未来将不受支持" + ] +} implementer { not-found = "找不到类 {}"