-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add launcher subproject and dummy fabric.mod.json
This lets us show an error message if the software is launched with an outdated version of Java
- Loading branch information
Showing
5 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
plugins { | ||
id 'java-library' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compileOnly 'org.slf4j:slf4j-api:2.0.13' | ||
} | ||
|
||
configurations { | ||
exports { | ||
canBeConsumed = true | ||
canBeResolved = false | ||
} | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(8)) | ||
vendor.set(JvmVendorSpec.ADOPTIUM) | ||
} | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
options.encoding = 'UTF-8' | ||
} | ||
|
||
artifacts { | ||
exports(jar) | ||
} |
41 changes: 41 additions & 0 deletions
41
Launcher/src/main/java/dev/upcraft/axiompatcher/LauncherMain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dev.upcraft.axiompatcher; | ||
|
||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
|
||
public class LauncherMain { | ||
|
||
public static void main(String[] args) { | ||
String javaVersion = System.getProperty("java.version"); | ||
int javaVersionNumber; | ||
String[] split = javaVersion.split("\\.", 3); | ||
if (javaVersion.startsWith("1.")) { | ||
javaVersionNumber = Integer.parseInt(split[1]); | ||
} else { | ||
javaVersionNumber = Integer.parseInt(split[0]); | ||
} | ||
|
||
if (javaVersionNumber < 17) { | ||
System.out.println("ERROR: You need to have Java 17 or higher installed to run this application."); | ||
JOptionPane.showMessageDialog(null, "You need to have Java 17 or higher installed to run this application.", "Error", JOptionPane.ERROR_MESSAGE); | ||
System.exit(1); | ||
} else { | ||
try { | ||
Class.forName("dev.upcraft.axiompatcher.Main").getDeclaredMethod("main", String[].class).invoke(null, (Object) args); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Unable to launch Axiom Patcher UI", e); | ||
} | ||
} | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public static void notAMinecraftMod() { | ||
LoggerFactory.getLogger(LauncherMain.class).error("AxiomPatcher is not a Minecraft mod, it must be run as standalone application."); | ||
if(!GraphicsEnvironment.isHeadless()) { | ||
JOptionPane.showMessageDialog(null, "AxiomPatcher is not a Minecraft mod, it must be run as standalone application.", "Error", JOptionPane.ERROR_MESSAGE); | ||
} | ||
System.exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ plugins { | |
} | ||
|
||
rootProject.name = 'AxiomPatcher' | ||
|
||
include 'Launcher' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"schemaVersion": 1, | ||
"id": "axiom-patcher", | ||
"name": "Axiom Patcher", | ||
"version": "${version}", | ||
"authors": [ | ||
"Up" | ||
], | ||
"entrypoints": { | ||
"preLaunch": [ | ||
"dev.upcraft.axiompatcher.LauncherMain::notAMinecraftMod" | ||
] | ||
} | ||
} |