Improves checking for whether a server should be delayed before starting
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2021-08-24 16:08:02 +02:00
parent 9532683301
commit 5e24d5daa8
2 changed files with 10 additions and 4 deletions

View File

@ -326,9 +326,10 @@ public class Server {
/** /**
* Runs a Minecraft server * Runs a Minecraft server
* *
* @param skipDelay <p>Whether to skip the startup delay for this server</p>
* @return <p>True if nothing went wrong</p> * @return <p>True if nothing went wrong</p>
*/ */
public boolean runServer(boolean isFirstServer) { public boolean runServer(boolean skipDelay) {
if (ServerHandler.stoppingServers()) { if (ServerHandler.stoppingServers()) {
gui.logMessage("Stopping servers. Cannot start yet."); gui.logMessage("Stopping servers. Cannot start yet.");
return false; return false;
@ -339,7 +340,7 @@ public class Server {
return true; return true;
} }
//Tries to do necessary pre-start work //Tries to do necessary pre-start work
if (!initializeJarDownload() || (!isFirstServer && !delayStartup())) { if (!initializeJarDownload() || (!skipDelay && !delayStartup())) {
gui.logError("Failed to perform startup tasks."); gui.logError("Failed to perform startup tasks.");
this.started = false; this.started = false;
return false; return false;

View File

@ -117,9 +117,11 @@ public class ServerHandler {
public static void startServers() { public static void startServers() {
ServerLauncherController controller = Main.getController(); ServerLauncherController controller = Main.getController();
gui.setStatus("Starting servers"); gui.setStatus("Starting servers");
int serverNum = 0; Server previouslyStartedServer = null;
for (Collection collection : controller.getCurrentProfile().getCollections()) { for (Collection collection : controller.getCurrentProfile().getCollections()) {
if (!collection.getServer().runServer(serverNum++ == 0)) { Server server = collection.getServer();
if (!server.runServer(previouslyStartedServer == null || previouslyStartedServer.isProxy())) {
gui.showError("An error occurred. Start aborted. Please check relevant log files."); gui.showError("An error occurred. Start aborted. Please check relevant log files.");
try { try {
stop(); stop();
@ -129,6 +131,9 @@ public class ServerHandler {
gui.updateGUIElementsWhenServersStartOrStop(false); gui.updateGUIElementsWhenServersStartOrStop(false);
return; return;
} }
if (server.isEnabled()) {
previouslyStartedServer = server;
}
} }
} }