From 992d31c8832dbe071756cd52d982a6f8c9df6dc2 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Tue, 16 Jul 2024 22:05:13 +0700 Subject: [PATCH] [FEATURE] Set netty bind port in first run --- .../gravit/launchserver/LaunchServerStarter.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index c3097c0c..16542fb6 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -241,11 +241,22 @@ public static void generateConfigIfNotExists(Path configFile, CommandHandler com logger.error("ProjectName null. Using MineCraft"); newConfig.projectName = "MineCraft"; } - + int port = 9274; + if(address.contains(":")) { + String portString = address.substring(address.indexOf(':')+1); + try { + port = Integer.parseInt(portString); + } catch (NumberFormatException e) { + logger.warn("Unknown port {}, using 9274", portString); + } + } else { + logger.info("Address {} doesn't contains port (you want to use nginx?)", address); + } newConfig.netty.address = "ws://" + address + "/api"; newConfig.netty.downloadURL = "http://" + address + "/%dirname%/"; newConfig.netty.launcherURL = "http://" + address + "/Launcher.jar"; newConfig.netty.launcherEXEURL = "http://" + address + "/Launcher.exe"; + newConfig.netty.binds[0].port = port; // Write LaunchServer config logger.info("Writing LaunchServer config file");