Headless mode

This commit is contained in:
Bixilon 2020-12-06 23:36:39 +01:00
parent 504534234b
commit 19afdf26ef
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 24 additions and 4 deletions

View File

@ -23,7 +23,7 @@ that I developed something useful, and people start contributing.
### Donating
I started this project inb mind, that I'll never earn money from it. Just doing it for fun, so I am not dependent on it. So: Currently not available and not planned.
I started this project in mind, that I'll never earn money from it. Just doing it for fun, so I am not dependent on it. So: Currently not available and not planned.
## Issue and MR rules
- Do not spam, we will answer when we have time.

View File

@ -60,6 +60,10 @@ public final class Minosoft {
taskWorker.setFatalError((exception) -> {
Log.fatal("Critical error occurred while preparing. Exit");
if (StaticConfiguration.HEADLESS_MODE) {
System.exit(1);
return;
}
try {
if (StartProgressWindow.toolkitLatch.getCount() == 2) {
StartProgressWindow.start();
@ -113,9 +117,19 @@ public final class Minosoft {
progress.countDown();
}, "Configuration", String.format("Load config file (%s)", StaticConfiguration.CONFIG_FILENAME), Priorities.HIGHEST, TaskImportance.REQUIRED));
taskWorker.addTask(new Task((progress) -> StartProgressWindow.start(), "JavaFX Toolkit", "Initialize JavaFX", Priorities.HIGHEST));
taskWorker.addTask(new Task((progress) -> {
if (StaticConfiguration.HEADLESS_MODE) {
return;
}
StartProgressWindow.start();
}, "JavaFX Toolkit", "Initialize JavaFX", Priorities.HIGHEST));
taskWorker.addTask(new Task((progress) -> StartProgressWindow.show(startStatusLatch), "Progress Window", "Display progress window", Priorities.HIGH, TaskImportance.OPTIONAL, "JavaFX Toolkit", "Configuration"));
taskWorker.addTask(new Task((progress) -> {
if (StaticConfiguration.HEADLESS_MODE) {
return;
}
StartProgressWindow.show(startStatusLatch);
}, "Progress Window", "Display progress window", Priorities.HIGH, TaskImportance.OPTIONAL, "JavaFX Toolkit", "Configuration"));
taskWorker.addTask(new Task(progress -> {
progress.countUp();
@ -171,6 +185,10 @@ public final class Minosoft {
} catch (InterruptedException e) {
e.printStackTrace();
}
Log.info("Everything initialized!");
if (StaticConfiguration.HEADLESS_MODE) {
return;
}
Launcher.start();
}

View File

@ -26,6 +26,7 @@ public class StaticConfiguration {
public static boolean COLORED_LOG = true; // the log should be colored with ANSI (does not affect base components)
public static boolean LOG_RELATIVE_TIME = false; // prefix all log messages with the relative start time in milliseconds instead of the formatted time
public static boolean VERBOSE_ENTITY_META_DATA_LOGGING = false; // if true, the entity meta data is getting serialized
public static boolean HEADLESS_MODE = false; // if true, no gui, rendering or whatever will be loaded or shown
public static String HOME_DIRECTORY;
public static final String TEMPORARY_FOLDER = System.getProperty("java.io.tmpdir", HOME_DIRECTORY + "/tmp/") + "/";

View File

@ -61,7 +61,8 @@ public class MinosoftCommandLineArguments {
registerCommandLineOption(new Option("verbose_entity_logging", true, "Should entity meta data be printed"), (value -> StaticConfiguration.VERBOSE_ENTITY_META_DATA_LOGGING = Boolean.parseBoolean(value)));
registerCommandLineOption(new Option("log_time_relativ", true, "Should time in log timestamp be relative"), (value -> StaticConfiguration.LOG_RELATIVE_TIME = Boolean.parseBoolean(value)));
registerCommandLineOption(new Option("config_filename", true, "The name of the config file (defaults to config.json)"), (value -> StaticConfiguration.CONFIG_FILENAME = value));
registerCommandLineOption(new Option("skip_mojang_authentication", true, "Debug: Disable all connections to mojang "), (value -> StaticConfiguration.SKIP_MOJANG_AUTHENTICATION = Boolean.parseBoolean(value)));
registerCommandLineOption(new Option("skip_mojang_authentication", true, "Debug: Disable all connections to mojang"), (value -> StaticConfiguration.SKIP_MOJANG_AUTHENTICATION = Boolean.parseBoolean(value)));
registerCommandLineOption(new Option("headless", true, "Disables all GUI parts"), (value -> StaticConfiguration.HEADLESS_MODE = Boolean.parseBoolean(value)));
}
public interface CommandLineArgumentHandler {