[FEATURE] Support port in launchserver address in first run

This commit is contained in:
Gravita 2024-07-16 21:54:59 +07:00
parent 0894e0b9c3
commit accbbe6b13
No known key found for this signature in database
GPG key ID: 543A8F335C9CD633

View file

@ -220,7 +220,7 @@ public static void generateConfigIfNotExists(Path configFile, CommandHandler com
address = System.getProperty("launchserver.address", null); address = System.getProperty("launchserver.address", null);
} }
if (address == null) { if (address == null) {
System.out.println("LaunchServer address(default: localhost): "); System.out.println("External launchServer address:port (default: localhost:9274): ");
address = commandHandler.readLine(); address = commandHandler.readLine();
} }
String projectName = System.getenv("PROJECTNAME"); String projectName = System.getenv("PROJECTNAME");
@ -234,18 +234,18 @@ public static void generateConfigIfNotExists(Path configFile, CommandHandler com
newConfig.setProjectName(projectName); newConfig.setProjectName(projectName);
} }
if (address == null || address.isEmpty()) { if (address == null || address.isEmpty()) {
logger.error("Address null. Using localhost"); logger.error("Address null. Using localhost:9274");
address = "localhost"; address = "localhost:9274";
} }
if (newConfig.projectName == null || newConfig.projectName.isEmpty()) { if (newConfig.projectName == null || newConfig.projectName.isEmpty()) {
logger.error("ProjectName null. Using MineCraft"); logger.error("ProjectName null. Using MineCraft");
newConfig.projectName = "MineCraft"; newConfig.projectName = "MineCraft";
} }
newConfig.netty.address = "ws://" + address + ":9274/api"; newConfig.netty.address = "ws://" + address + "/api";
newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; newConfig.netty.downloadURL = "http://" + address + "/%dirname%/";
newConfig.netty.launcherURL = "http://" + address + ":9274/Launcher.jar"; newConfig.netty.launcherURL = "http://" + address + "/Launcher.jar";
newConfig.netty.launcherEXEURL = "http://" + address + ":9274/Launcher.exe"; newConfig.netty.launcherEXEURL = "http://" + address + "/Launcher.exe";
// Write LaunchServer config // Write LaunchServer config
logger.info("Writing LaunchServer config file"); logger.info("Writing LaunchServer config file");