Fix early logs being written to wrong backend

This commit is contained in:
Johannes Frohnmeyer 2022-09-06 21:38:54 +02:00
parent c7aafad507
commit 165cad8e6b
Signed by: Johannes
GPG Key ID: E76429612C2929F4
3 changed files with 2 additions and 6 deletions

View File

@ -36,7 +36,7 @@ public class CliMain {
}
public static void main(String[] args) throws Exception {
LauncherEnv.checkClassLoaderState();
LauncherEnv.initialize(new CliEnvBackend());
CommandResolution command = resolve(args);
if (command.command().enableLog()) {
@ -44,7 +44,6 @@ public class CliMain {
Utils.LOGGER.info("Loading from " + MetaHolder.BASE_PATH);
}
LauncherEnv.initialize(new CliEnvBackend());
try {
command.invoke();
} finally {

View File

@ -41,7 +41,6 @@ public class GuiMain {
private static String glslVersion = null;
public static void main(String[] args) throws IOException {
LauncherEnv.checkClassLoaderState();
LauncherEnv.initialize(new GuiEnvBackend());
Utils.LOGGER.info("Launching Inceptum v" + BuildMetadata.VERSION);
Utils.LOGGER.info("Loading from " + MetaHolder.BASE_PATH);

View File

@ -19,13 +19,11 @@ import java.util.function.Consumer;
public class LauncherEnv {
private static EnvBackend backend;
public static void checkClassLoaderState() {
public static void initialize(EnvBackend backend) throws IOException {
if (MetaHolder.class.getClassLoader() != LauncherEnv.class.getClassLoader()) {
throw new IllegalStateException("Mismatching classloader between two classes. Something is wrong here");
}
}
public static void initialize(EnvBackend backend) throws IOException {
LauncherEnv.backend = backend;
GsonHolder.registerTypeAdapter(MinecraftArgument.class, new MinecraftArgumentDeserializer());