diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index a87bf31..3724edc 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -54,7 +54,7 @@
1779565206518
-
+
diff --git a/src/main/java/org/strassburger/mcrun/RunServerMojo.java b/src/main/java/org/strassburger/mcrun/RunServerMojo.java
index f11d540..b00abae 100644
--- a/src/main/java/org/strassburger/mcrun/RunServerMojo.java
+++ b/src/main/java/org/strassburger/mcrun/RunServerMojo.java
@@ -94,8 +94,13 @@ public class RunServerMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
- getLog().info("Server directory: " + serverDirectory.getAbsolutePath());
+ copyPlugin();
+ downloadServerJar();
+ if (acceptEula) acceptEula();
+ startServerProcess();
+ }
+ private void copyPlugin() throws MojoExecutionException {
File pluginsDir = new File(serverDirectory, "plugins");
pluginsDir.mkdirs();
try {
@@ -105,7 +110,9 @@ public class RunServerMojo extends AbstractMojo {
} catch (IOException e) {
throw new MojoExecutionException("Failed to copy plugin jar file: " + pluginJar.getAbsolutePath(), e);
}
+ }
+ private void downloadServerJar() throws MojoExecutionException {
try {
ServerJarDownloader jarDownloader = ServerJarDownloader.forServerSoftware(serverSoftware)
.withLog(getLog()).withServerDirectory(serverDirectory)
@@ -115,25 +122,16 @@ public class RunServerMojo extends AbstractMojo {
} catch (ServerJarDownloadException e) {
throw new MojoExecutionException("Failed to download server jar", e);
}
+ }
- if (acceptEula) acceptEula();
-
- List command = buildCommand();
- getLog().info("Starting server with command: " + String.join(" ", command));
-
- ProcessBuilder pb = new ProcessBuilder(command);
- pb.directory(serverDirectory);
- pb.inheritIO();
- Process process;
+ private void acceptEula() throws MojoExecutionException {
+ File eula = new File(serverDirectory, "eula.txt");
+ if (eula.exists()) return;
try {
- process = pb.start();
+ Files.writeString(eula.toPath(), "eula=true\n");
+ getLog().info("eula.txt created and accepted.");
} catch (IOException e) {
- throw new MojoExecutionException("Failed to start server: " + e.getMessage(), e);
- }
- try {
- process.waitFor();
- } catch (InterruptedException e) {
- throw new MojoExecutionException("Failed to start server: " + e.getMessage(), e);
+ throw new MojoExecutionException("Failed to write eula.txt: " + e.getMessage(), e);
}
}
@@ -153,14 +151,19 @@ public class RunServerMojo extends AbstractMojo {
return cmd;
}
- private void acceptEula() throws MojoExecutionException {
- File eula = new File(serverDirectory, "eula.txt");
- if (eula.exists()) return;
+ private void startServerProcess() throws MojoExecutionException {
+ List command = buildCommand();
+ getLog().info("Starting server with command: " + String.join(" ", command));
+
+ ProcessBuilder pb = new ProcessBuilder(command);
+ pb.directory(serverDirectory);
+ pb.inheritIO();
+ Process process;
try {
- Files.writeString(eula.toPath(), "eula=true\n");
- getLog().info("eula.txt created and accepted.");
- } catch (IOException e) {
- throw new MojoExecutionException("Failed to write eula.txt: " + e.getMessage(), e);
+ process = pb.start();
+ process.waitFor();
+ } catch (IOException | InterruptedException e) {
+ throw new MojoExecutionException("Failed to start server: " + e.getMessage(), e);
}
}
}
\ No newline at end of file