3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-19 14:30:17 +01:00

Add an extra headless check to fix occational errors (#945)

* Add an extra headless check

* Update GeyserStandaloneBootstrap.java

* Rename checkHeadless to isHeadless
Dieser Commit ist enthalten in:
rtm516 2020-07-14 00:20:56 +01:00 committet von GitHub
Ursprung e7657c7d07
Commit 0a14e3c441
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -46,6 +46,7 @@ import org.geysermc.platform.standalone.gui.GeyserStandaloneGUI;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.UUID;
@ -60,7 +61,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
private GeyserStandaloneGUI gui;
@Getter
private boolean useGui = System.console() == null;
private boolean useGui = System.console() == null && !isHeadless();
private GeyserConnector connector;
@ -127,6 +128,21 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
}
}
/**
* Check using {@link java.awt.GraphicsEnvironment} that we are a headless client
*
* @return If the current environment is headless
*/
private boolean isHeadless() {
try {
Class<?> graphicsEnv = Class.forName("java.awt.GraphicsEnvironment");
Method isHeadless = graphicsEnv.getDeclaredMethod("isHeadless");
return (boolean) isHeadless.invoke(null);
} catch (Exception ignore) { }
return true;
}
@Override
public void onDisable() {
connector.shutdown();