Skip to content

Commit

Permalink
Automatically install a server on headless environments (#38)
Browse files Browse the repository at this point in the history
This PR makes the installer automatically install a server on headless environments without needing the `--install-server` option specified. This should reduce user confusion when they try to simply run the jar on a server
  • Loading branch information
Matyrobbrt authored Dec 8, 2024
1 parent 3876faf commit 905b79d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ dependencies {
testImplementation(platform('org.junit:junit-bom:5.7.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
compileOnly 'org.jetbrains:annotations:24.1.0'
testInstallerData 'net.neoforged:neoforge:20.4.76-beta:installer'
testInstallerData 'net.neoforged:neoforge:21.4.10-beta:installer'
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package net.minecraftforge.installer;

import java.awt.GraphicsEnvironment;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -155,6 +156,13 @@ public static void main(String[] args) throws IOException, URISyntaxException {
}
}

if (action == null && GraphicsEnvironment.isHeadless()) {
monitor.message("No action was specified but headless environment was detected... Installing server");
action = Actions.SERVER;
target = optionSet.valueOf(serverInstallOption);
ServerInstall.serverStarterJar = true;
}

if (action != null) {
try {
SimpleInstaller.headless = true;
Expand Down

0 comments on commit 905b79d

Please sign in to comment.