Implemented the autoStart feature into the ServerManager
This commit is contained in:
parent
36b59f8316
commit
677bde3c82
@ -42,8 +42,10 @@ public class ServerManager {
|
|||||||
|
|
||||||
servers.forEach(server -> {
|
servers.forEach(server -> {
|
||||||
if (server.getStatus() == ServerStatus.ONLINE) return;
|
if (server.getStatus() == ServerStatus.ONLINE) return;
|
||||||
startServer(server);
|
if (server.getConfiguration().isAutoStart()) startServer(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
LOG.info("All servers have been started");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@ public class ServerConfiguration {
|
|||||||
private String version;
|
private String version;
|
||||||
private String description;
|
private String description;
|
||||||
private int memory;
|
private int memory;
|
||||||
|
private boolean autoStart;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a server configuration from a file
|
* Loads a server configuration from a file
|
||||||
@ -101,6 +102,14 @@ public class ServerConfiguration {
|
|||||||
return memory;
|
return memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the auto start of the server
|
||||||
|
* @return The auto start of the server
|
||||||
|
*/
|
||||||
|
public boolean isAutoStart() {
|
||||||
|
return autoStart;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the description of the server
|
* Sets the description of the server
|
||||||
*
|
*
|
||||||
@ -150,4 +159,13 @@ public class ServerConfiguration {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the auto start of the server
|
||||||
|
* @param autoStart The new auto start of the server
|
||||||
|
*/
|
||||||
|
public void setAutoStart(boolean autoStart) {
|
||||||
|
this.autoStart = autoStart;
|
||||||
|
save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
package de.gnmyt.mcdash.routes.server;
|
||||||
|
|
||||||
|
import de.gnmyt.mcdash.handler.DefaultHandler;
|
||||||
|
import de.gnmyt.mcdash.http.Request;
|
||||||
|
import de.gnmyt.mcdash.http.ResponseController;
|
||||||
|
|
||||||
|
public class ServerStartRoute extends DefaultHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String path() {
|
||||||
|
return "start";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void post(Request request, ResponseController response) throws Exception {
|
||||||
|
response.text("The server is already running");
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user