mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-12-22 16:38:04 +01:00
Load Via async again
This commit is contained in:
parent
0c23bd42ff
commit
5e0b5a9a69
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package net.raphimc.viaproxy;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.group.ChannelGroup;
|
||||
import io.netty.channel.group.DefaultChannelGroup;
|
||||
@ -30,12 +31,12 @@ import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
||||
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
||||
import net.lenni0451.lambdaevents.LambdaManager;
|
||||
import net.lenni0451.lambdaevents.generator.LambdaMetaFactoryGenerator;
|
||||
import net.lenni0451.reflect.Agents;
|
||||
import net.lenni0451.reflect.ClassLoaders;
|
||||
import net.lenni0451.reflect.JavaBypass;
|
||||
import net.lenni0451.reflect.Methods;
|
||||
import net.lenni0451.reflect.*;
|
||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||
import net.raphimc.netminecraft.netty.connection.NetServer;
|
||||
import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion;
|
||||
import net.raphimc.viabedrock.api.BedrockProtocolVersion;
|
||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||
import net.raphimc.viaproxy.cli.ConsoleHandler;
|
||||
import net.raphimc.viaproxy.cli.options.Options;
|
||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||
@ -43,11 +44,11 @@ import net.raphimc.viaproxy.plugins.events.Client2ProxyHandlerCreationEvent;
|
||||
import net.raphimc.viaproxy.plugins.events.ProxyStartEvent;
|
||||
import net.raphimc.viaproxy.plugins.events.ProxyStopEvent;
|
||||
import net.raphimc.viaproxy.plugins.events.ViaProxyLoadedEvent;
|
||||
import net.raphimc.viaproxy.protocoltranslator.ProtocolTranslator;
|
||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
|
||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyHandler;
|
||||
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
||||
import net.raphimc.viaproxy.saves.SaveManager;
|
||||
import net.raphimc.viaproxy.tasks.LoaderTask;
|
||||
import net.raphimc.viaproxy.tasks.UpdateCheckTask;
|
||||
import net.raphimc.viaproxy.ui.ViaProxyUI;
|
||||
import net.raphimc.viaproxy.ui.events.UIInitEvent;
|
||||
@ -136,14 +137,19 @@ public class ViaProxy {
|
||||
ConsoleHandler.hookConsole();
|
||||
ClassLoaderPriorityUtil.loadOverridingJars();
|
||||
ViaProxy.loadNetty();
|
||||
ProtocolTranslator.init();
|
||||
Classes.ensureInitialized(ProtocolVersion.class);
|
||||
Classes.ensureInitialized(LegacyProtocolVersion.class);
|
||||
Classes.ensureInitialized(AprilFoolsProtocolVersion.class);
|
||||
Classes.ensureInitialized(BedrockProtocolVersion.class);
|
||||
|
||||
SAVE_MANAGER = new SaveManager();
|
||||
PLUGIN_MANAGER = new PluginManager();
|
||||
|
||||
final Thread loaderThread = new Thread(new LoaderTask(), "ViaLoader");
|
||||
final Thread updateCheckThread = new Thread(new UpdateCheckTask(hasUI), "UpdateCheck");
|
||||
|
||||
if (hasUI) {
|
||||
loaderThread.start();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
try {
|
||||
ui = new ViaProxyUI();
|
||||
@ -155,6 +161,7 @@ public class ViaProxy {
|
||||
if (System.getProperty("skipUpdateCheck") == null) {
|
||||
updateCheckThread.start();
|
||||
}
|
||||
loaderThread.join();
|
||||
ui.eventManager.call(new UIInitEvent());
|
||||
EVENT_MANAGER.call(new ViaProxyLoadedEvent());
|
||||
Logger.LOGGER.info("ViaProxy started successfully!");
|
||||
@ -164,6 +171,8 @@ public class ViaProxy {
|
||||
if (System.getProperty("skipUpdateCheck") == null) {
|
||||
updateCheckThread.start();
|
||||
}
|
||||
loaderThread.start();
|
||||
loaderThread.join();
|
||||
EVENT_MANAGER.call(new ViaProxyLoadedEvent());
|
||||
Logger.LOGGER.info("ViaProxy started successfully!");
|
||||
startProxy();
|
||||
|
29
src/main/java/net/raphimc/viaproxy/tasks/LoaderTask.java
Normal file
29
src/main/java/net/raphimc/viaproxy/tasks/LoaderTask.java
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
||||
* Copyright (C) 2021-2024 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.raphimc.viaproxy.tasks;
|
||||
|
||||
import net.raphimc.viaproxy.protocoltranslator.ProtocolTranslator;
|
||||
|
||||
public class LoaderTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ProtocolTranslator.init();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user