From d7b65ae5e0e04a2d3813a6681626147d255791b8 Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:06:16 +0100 Subject: [PATCH] Open loading screen earlier --- .../java/net/raphimc/viaproxy/ViaProxy.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/main/java/net/raphimc/viaproxy/ViaProxy.java b/src/main/java/net/raphimc/viaproxy/ViaProxy.java index 59c6c57..e16f9a8 100644 --- a/src/main/java/net/raphimc/viaproxy/ViaProxy.java +++ b/src/main/java/net/raphimc/viaproxy/ViaProxy.java @@ -104,9 +104,24 @@ public class ViaProxy { } public static void injectedMain(final String injectionMethod, final String[] args) throws InterruptedException, IOException, InvocationTargetException { - Logger.setup(); - final boolean hasUI = args.length == 0 && !GraphicsEnvironment.isHeadless(); + final SplashScreen splashScreen; + final Consumer progressConsumer; + if (hasUI) { + final float progressStep = 1F / 6F; + splashScreen = new SplashScreen(); + progressConsumer = (text) -> { + splashScreen.setProgress(splashScreen.getProgress() + progressStep); + splashScreen.setText(text); + }; + } else { + splashScreen = null; + progressConsumer = text -> { + }; + } + progressConsumer.accept("Initializing ViaProxy"); + + Logger.setup(); Logger.LOGGER.info("Initializing ViaProxy {} v{} ({}) (Injected using {})...", hasUI ? "GUI" : "CLI", VERSION, IMPL_VERSION, injectionMethod); Logger.LOGGER.info("Using java version: " + System.getProperty("java.vm.name") + " " + System.getProperty("java.version") + " (" + System.getProperty("java.vendor") + ") on " + System.getProperty("os.name")); Logger.LOGGER.info("Available memory (bytes): " + Runtime.getRuntime().maxMemory()); @@ -135,25 +150,9 @@ public class ViaProxy { } } - final SplashScreen splashScreen; - final Consumer progressConsumer; - if (hasUI) { - final float progressStep = 1F / 7F; - splashScreen = new SplashScreen(); - progressConsumer = (text) -> { - splashScreen.setProgress(splashScreen.getProgress() + progressStep); - splashScreen.setText(text); - }; - } else { - splashScreen = null; - progressConsumer = text -> { - }; - } - progressConsumer.accept("Initializing ViaProxy"); ConsoleHandler.hookConsole(); ViaProxy.loadNetty(); - progressConsumer.accept("Loading Overriding Jars"); ClassLoaderPriorityUtil.loadOverridingJars(); progressConsumer.accept("Loading Protocol Translators"); ProtocolTranslator.init();