Skip to content

Commit

Permalink
[FEATURE] Set netty bind port in first run
Browse files Browse the repository at this point in the history
  • Loading branch information
gravit0 committed Jul 16, 2024
1 parent accbbe6 commit 992d31c
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 992d31c

Please sign in to comment.