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:
Ursprung
e7657c7d07
Commit
0a14e3c441
@ -46,6 +46,7 @@ import org.geysermc.platform.standalone.gui.GeyserStandaloneGUI;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -60,7 +61,7 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
|
|||||||
private GeyserStandaloneGUI gui;
|
private GeyserStandaloneGUI gui;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private boolean useGui = System.console() == null;
|
private boolean useGui = System.console() == null && !isHeadless();
|
||||||
|
|
||||||
private GeyserConnector connector;
|
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
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
connector.shutdown();
|
connector.shutdown();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren