Pass launcher.server system property from Bootstrap to JFXLauncher

This commit is contained in:
SashegDev
2026-05-08 18:38:18 +00:00
parent 74cd5ffdf3
commit 099df80cc6
2 changed files with 14 additions and 4 deletions
@@ -182,9 +182,17 @@ public class Bootstrap {
"-Dfile.encoding=UTF-8", "-Dfile.encoding=UTF-8",
"-Dsun.stdout.encoding=UTF-8", "-Dsun.stdout.encoding=UTF-8",
"-Dsun.stderr.encoding=UTF-8", "-Dsun.stderr.encoding=UTF-8",
"-Dlauncher.server=" + BASE_URL,
"--module-path", javafxPath.toAbsolutePath().toString(), "--module-path", javafxPath.toAbsolutePath().toString(),
"--add-modules", "javafx.controls,javafx.web" "--add-modules", "javafx.controls,javafx.web"
); );
} else {
jvmArgs = List.of(
"-Dfile.encoding=UTF-8",
"-Dsun.stdout.encoding=UTF-8",
"-Dsun.stderr.encoding=UTF-8",
"-Dlauncher.server=" + BASE_URL
);
} }
List<String> cmd = new ArrayList<>(); List<String> cmd = new ArrayList<>();
@@ -215,7 +223,8 @@ public class Bootstrap {
List<String> jvmArgs = List.of( List<String> jvmArgs = List.of(
"-Dfile.encoding=UTF-8", "-Dfile.encoding=UTF-8",
"-Dsun.stdout.encoding=UTF-8", "-Dsun.stdout.encoding=UTF-8",
"-Dsun.stderr.encoding=UTF-8" "-Dsun.stderr.encoding=UTF-8",
"-Dlauncher.server=" + BASE_URL
); );
List<String> cmd = new ArrayList<>(); List<String> cmd = new ArrayList<>();
@@ -38,6 +38,7 @@ import com.sun.net.httpserver.Headers;
public class JFXLauncher extends Application { public class JFXLauncher extends Application {
private static final int PORT = 8080; private static final int PORT = 8080;
private static final String APP_TITLE = "ZernMC Launcher"; private static final String APP_TITLE = "ZernMC Launcher";
private static final String LAUNCHER_SERVER = System.getProperty("launcher.server", "http://87.120.187.36:1582");
private final LauncherAPI api = new LauncherAPI(); private final LauncherAPI api = new LauncherAPI();
private final Gson gson = new Gson(); private final Gson gson = new Gson();
private HttpServer server; private HttpServer server;
@@ -129,7 +130,7 @@ public class JFXLauncher extends Application {
private static String getServerVersion() { private static String getServerVersion() {
try { try {
URL url = new URL("http://localhost:1582/launcher/version"); URL url = new URL(LAUNCHER_SERVER + "/launcher/version");
HttpURLConnection conn = (HttpURLConnection) url.openConnection(); HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(3000); conn.setConnectTimeout(3000);
conn.setReadTimeout(3000); conn.setReadTimeout(3000);
@@ -155,7 +156,7 @@ public class JFXLauncher extends Application {
private static boolean downloadAssetsFromMeta(String version) { private static boolean downloadAssetsFromMeta(String version) {
try { try {
URL metaUrl = new URL("http://localhost:1582/launcher/meta/" + version); URL metaUrl = new URL(LAUNCHER_SERVER + "/launcher/meta/" + version);
HttpURLConnection conn = (HttpURLConnection) metaUrl.openConnection(); HttpURLConnection conn = (HttpURLConnection) metaUrl.openConnection();
conn.setConnectTimeout(5000); conn.setConnectTimeout(5000);
conn.setReadTimeout(10000); conn.setReadTimeout(10000);
@@ -174,7 +175,7 @@ public class JFXLauncher extends Application {
org.json.JSONObject file = (org.json.JSONObject) fileObj; org.json.JSONObject file = (org.json.JSONObject) fileObj;
String path = file.getString("path"); String path = file.getString("path");
if (path.startsWith("assets/")) { if (path.startsWith("assets/")) {
String downloadUrl = "http://localhost:1582/launcher/file/" + version + "/" + path; String downloadUrl = LAUNCHER_SERVER + "/launcher/file/" + version + "/" + path;
Path outPath = assetsDir.resolve(path.substring(7)); Path outPath = assetsDir.resolve(path.substring(7));
Files.createDirectories(outPath.getParent()); Files.createDirectories(outPath.getParent());