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

View File

@ -117,9 +117,11 @@ public class ServerHandler {
public static void startServers() {
ServerLauncherController controller = Main.getController();
gui.setStatus("Starting servers");
int serverNum = 0;
Server previouslyStartedServer = null;
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.");
try {
stop();
@ -129,6 +131,9 @@ public class ServerHandler {
gui.updateGUIElementsWhenServersStartOrStop(false);
return;
}
if (server.isEnabled()) {
previouslyStartedServer = server;
}
}
}