mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
quick-e2e: Add StartServerService to initiate server process and update Main class
This commit is contained in:
@@ -5,6 +5,7 @@ import de.oliver.quicke2e.config.Context;
|
|||||||
import de.oliver.quicke2e.steps.eula.EulaService;
|
import de.oliver.quicke2e.steps.eula.EulaService;
|
||||||
import de.oliver.quicke2e.steps.paper.PaperDownloadService;
|
import de.oliver.quicke2e.steps.paper.PaperDownloadService;
|
||||||
import de.oliver.quicke2e.steps.startScript.StartScriptService;
|
import de.oliver.quicke2e.steps.startScript.StartScriptService;
|
||||||
|
import de.oliver.quicke2e.steps.startServer.StartServerService;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
@@ -31,6 +32,9 @@ public class Main {
|
|||||||
|
|
||||||
StartScriptService startScript = new StartScriptService();
|
StartScriptService startScript = new StartScriptService();
|
||||||
startScript.writeStartScript(context);
|
startScript.writeStartScript(context);
|
||||||
|
|
||||||
|
StartServerService startServer = new StartServerService();
|
||||||
|
startServer.startServer(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ public class PaperDownloadService {
|
|||||||
Path filePath = Paths.get(String.format("%s/%s_%s_%s/%s-%s-%s.jar", destination, type, version, build, type, version, buildNumber));
|
Path filePath = Paths.get(String.format("%s/%s_%s_%s/%s-%s-%s.jar", destination, type, version, build, type, version, buildNumber));
|
||||||
context.setServerJarPath(filePath);
|
context.setServerJarPath(filePath);
|
||||||
|
|
||||||
|
if (filePath.toFile().exists()) {
|
||||||
|
System.out.println("Server file already exists, skipping download");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
HttpRequest req = HttpRequest.newBuilder()
|
HttpRequest req = HttpRequest.newBuilder()
|
||||||
.GET()
|
.GET()
|
||||||
.uri(URI.create(String.format("%s/projects/%s/versions/%s/builds/%s/downloads/%s-%s-%s.jar", BASE_URL, type, version, buildNumber, type, version, buildNumber)))
|
.uri(URI.create(String.format("%s/projects/%s/versions/%s/builds/%s/downloads/%s-%s-%s.jar", BASE_URL, type, version, buildNumber, type, version, buildNumber)))
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package de.oliver.quicke2e.steps.startServer;
|
||||||
|
|
||||||
|
import de.oliver.quicke2e.config.Context;
|
||||||
|
|
||||||
|
public class StartServerService {
|
||||||
|
|
||||||
|
public void startServer(Context context) {
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", context.serverFileName());
|
||||||
|
processBuilder.directory(context.serverEnvPath().toFile());
|
||||||
|
processBuilder.redirectErrorStream(true);
|
||||||
|
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
|
||||||
|
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
|
||||||
|
|
||||||
|
try {
|
||||||
|
processBuilder.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user