Skip to content

Commit

Permalink
Java version warning
Browse files Browse the repository at this point in the history
  • Loading branch information
IzzelAliz committed May 12, 2021
1 parent 32d233f commit b2b9a08
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@

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) {
Expand Down
16 changes: 15 additions & 1 deletion arclight-forge-1.16/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand All @@ -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 {
Expand All @@ -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/**'
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
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);
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
allprojects {
group 'io.izzel.arclight'
version '1.0.18'
version '1.0.19-SNAPSHOT'

ext {
agpVersion = '1.15'
Expand Down
7 changes: 7 additions & 0 deletions i18n-config/src/main/resources/META-INF/i18n/en_us.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}"
Expand Down
7 changes: 7 additions & 0 deletions i18n-config/src/main/resources/META-INF/i18n/zh_cn.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ downloader {
forge-install = "即将开始 Forge 安装,请等待一段时间"
access-denied = "没有对 {0} 操作的权限: {1}"
}
java {
deprecated = [
"您正在使用过时的 Java 版本"
"当前版本 {0} 推荐使用 {1}"
"该版本的 Java 未来将不受支持"
]
}

implementer {
not-found = "找不到类 {}"
Expand Down

0 comments on commit b2b9a08

Please sign in to comment.