mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-22 11:55:24 +01:00
Structural refactor
This commit is contained in:
parent
f97405604d
commit
ac5fe1263b
@ -28,8 +28,11 @@ import net.lenni0451.classtransform.mixinstranslator.MixinsTranslator;
|
|||||||
import net.lenni0451.classtransform.utils.loader.EnumLoaderPriority;
|
import net.lenni0451.classtransform.utils.loader.EnumLoaderPriority;
|
||||||
import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
||||||
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
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.Agents;
|
||||||
import net.lenni0451.reflect.ClassLoaders;
|
import net.lenni0451.reflect.ClassLoaders;
|
||||||
|
import net.lenni0451.reflect.JavaBypass;
|
||||||
import net.lenni0451.reflect.Methods;
|
import net.lenni0451.reflect.Methods;
|
||||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||||
import net.raphimc.netminecraft.netty.connection.NetServer;
|
import net.raphimc.netminecraft.netty.connection.NetServer;
|
||||||
@ -61,11 +64,14 @@ public class ViaProxy {
|
|||||||
public static final String VERSION = "${version}";
|
public static final String VERSION = "${version}";
|
||||||
public static final String IMPL_VERSION = "${impl_version}";
|
public static final String IMPL_VERSION = "${impl_version}";
|
||||||
|
|
||||||
|
public static final LambdaManager EVENT_MANAGER = LambdaManager.threadSafe(new LambdaMetaFactoryGenerator(JavaBypass.TRUSTED_LOOKUP));
|
||||||
|
private static /*final*/ SaveManager SAVE_MANAGER;
|
||||||
|
private static /*final*/ PluginManager PLUGIN_MANAGER;
|
||||||
|
private static /*final*/ ChannelGroup CLIENT_CHANNELS;
|
||||||
|
|
||||||
private static Instrumentation instrumentation;
|
private static Instrumentation instrumentation;
|
||||||
public static SaveManager saveManager;
|
private static NetServer currentProxyServer;
|
||||||
public static NetServer currentProxyServer;
|
private static ViaProxyUI ui;
|
||||||
public static ChannelGroup c2pChannels;
|
|
||||||
public static ViaProxyUI ui;
|
|
||||||
|
|
||||||
public static void agentmain(final String args, final Instrumentation instrumentation) {
|
public static void agentmain(final String args, final Instrumentation instrumentation) {
|
||||||
ViaProxy.instrumentation = instrumentation;
|
ViaProxy.instrumentation = instrumentation;
|
||||||
@ -96,8 +102,8 @@ public class ViaProxy {
|
|||||||
|
|
||||||
public static void injectedMain(final String injectionMethod, final String[] args) throws InterruptedException, IOException {
|
public static void injectedMain(final String injectionMethod, final String[] args) throws InterruptedException, IOException {
|
||||||
Logger.setup();
|
Logger.setup();
|
||||||
|
|
||||||
final boolean hasUI = args.length == 0 && !GraphicsEnvironment.isHeadless();
|
final boolean hasUI = args.length == 0 && !GraphicsEnvironment.isHeadless();
|
||||||
ConsoleHandler.hookConsole();
|
|
||||||
Logger.LOGGER.info("Initializing ViaProxy {} v{} ({}) (Injected using {})...", hasUI ? "GUI" : "CLI", VERSION, IMPL_VERSION, injectionMethod);
|
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("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());
|
Logger.LOGGER.info("Available memory (bytes): " + Runtime.getRuntime().maxMemory());
|
||||||
@ -125,11 +131,13 @@ public class ViaProxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConsoleHandler.hookConsole();
|
||||||
ClassLoaderPriorityUtil.loadOverridingJars();
|
ClassLoaderPriorityUtil.loadOverridingJars();
|
||||||
loadNetty();
|
loadNetty();
|
||||||
saveManager = new SaveManager();
|
|
||||||
PluginManager.loadPlugins();
|
SAVE_MANAGER = new SaveManager();
|
||||||
PluginManager.EVENT_MANAGER.register(EventListener.class);
|
PLUGIN_MANAGER = new PluginManager();
|
||||||
|
EVENT_MANAGER.register(EventListener.class);
|
||||||
|
|
||||||
final Thread loaderThread = new Thread(new LoaderTask(), "ViaLoader");
|
final Thread loaderThread = new Thread(new LoaderTask(), "ViaLoader");
|
||||||
final Thread updateCheckThread = new Thread(new UpdateCheckTask(hasUI), "UpdateCheck");
|
final Thread updateCheckThread = new Thread(new UpdateCheckTask(hasUI), "UpdateCheck");
|
||||||
@ -152,7 +160,7 @@ public class ViaProxy {
|
|||||||
Logger.LOGGER.info("Waiting for UI to be initialized...");
|
Logger.LOGGER.info("Waiting for UI to be initialized...");
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
}
|
}
|
||||||
ViaProxyUI.EVENT_MANAGER.call(new UIInitEvent());
|
ui.eventManager.call(new UIInitEvent());
|
||||||
Logger.LOGGER.info("ViaProxy started successfully!");
|
Logger.LOGGER.info("ViaProxy started successfully!");
|
||||||
} else {
|
} else {
|
||||||
Options.parse(args);
|
Options.parse(args);
|
||||||
@ -177,8 +185,8 @@ public class ViaProxy {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Logger.LOGGER.info("Starting proxy server");
|
Logger.LOGGER.info("Starting proxy server");
|
||||||
currentProxyServer = new NetServer(() -> PluginManager.EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler(), false)).getHandler(), Client2ProxyChannelInitializer::new);
|
currentProxyServer = new NetServer(() -> EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler(), false)).getHandler(), Client2ProxyChannelInitializer::new);
|
||||||
PluginManager.EVENT_MANAGER.call(new ProxyStartEvent());
|
EVENT_MANAGER.call(new ProxyStartEvent());
|
||||||
Logger.LOGGER.info("Binding proxy server to " + Options.BIND_ADDRESS + ":" + Options.BIND_PORT);
|
Logger.LOGGER.info("Binding proxy server to " + Options.BIND_ADDRESS + ":" + Options.BIND_PORT);
|
||||||
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
|
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@ -190,12 +198,12 @@ public class ViaProxy {
|
|||||||
public static void stopProxy() {
|
public static void stopProxy() {
|
||||||
if (currentProxyServer != null) {
|
if (currentProxyServer != null) {
|
||||||
Logger.LOGGER.info("Stopping proxy server");
|
Logger.LOGGER.info("Stopping proxy server");
|
||||||
PluginManager.EVENT_MANAGER.call(new ProxyStopEvent());
|
EVENT_MANAGER.call(new ProxyStopEvent());
|
||||||
|
|
||||||
currentProxyServer.getChannel().close();
|
currentProxyServer.getChannel().close();
|
||||||
currentProxyServer = null;
|
currentProxyServer = null;
|
||||||
|
|
||||||
for (Channel channel : c2pChannels) {
|
for (Channel channel : CLIENT_CHANNELS) {
|
||||||
try {
|
try {
|
||||||
ProxyConnection.fromChannel(channel).kickClient("§cViaProxy has been stopped");
|
ProxyConnection.fromChannel(channel).kickClient("§cViaProxy has been stopped");
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
@ -210,7 +218,27 @@ public class ViaProxy {
|
|||||||
System.setProperty("io.netty.allocator.maxOrder", "9");
|
System.setProperty("io.netty.allocator.maxOrder", "9");
|
||||||
}
|
}
|
||||||
MCPipeline.useOptimizedPipeline();
|
MCPipeline.useOptimizedPipeline();
|
||||||
c2pChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
|
CLIENT_CHANNELS = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SaveManager getSaveManager() {
|
||||||
|
return SAVE_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PluginManager getPluginManager() {
|
||||||
|
return PLUGIN_MANAGER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ChannelGroup getConnectedClients() {
|
||||||
|
return CLIENT_CHANNELS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetServer getCurrentProxyServer() {
|
||||||
|
return currentProxyServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ViaProxyUI getUI() {
|
||||||
|
return ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
package net.raphimc.viaproxy.cli;
|
package net.raphimc.viaproxy.cli;
|
||||||
|
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.plugins.events.ConsoleCommandEvent;
|
import net.raphimc.viaproxy.plugins.events.ConsoleCommandEvent;
|
||||||
import net.raphimc.viaproxy.protocolhack.viaproxy.ConsoleCommandSender;
|
import net.raphimc.viaproxy.protocolhack.viaproxy.ConsoleCommandSender;
|
||||||
import net.raphimc.viaproxy.util.ArrayHelper;
|
import net.raphimc.viaproxy.util.ArrayHelper;
|
||||||
@ -67,7 +67,7 @@ public class ConsoleHandler {
|
|||||||
for (StackTraceElement element : thread.getStackTrace()) System.out.println(" " + element.toString());
|
for (StackTraceElement element : thread.getStackTrace()) System.out.println(" " + element.toString());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (PluginManager.EVENT_MANAGER.call(new ConsoleCommandEvent(command, args.getAsArray())).isCancelled()) continue;
|
if (ViaProxy.EVENT_MANAGER.call(new ConsoleCommandEvent(command, args.getAsArray())).isCancelled()) continue;
|
||||||
System.out.println("Invalid Command!");
|
System.out.println("Invalid Command!");
|
||||||
System.out.println(" gc | Run the garbage collector");
|
System.out.println(" gc | Run the garbage collector");
|
||||||
System.out.println(" exit | Shutdown ViaProxy");
|
System.out.println(" exit | Shutdown ViaProxy");
|
||||||
|
@ -23,7 +23,6 @@ import joptsimple.OptionSet;
|
|||||||
import joptsimple.OptionSpec;
|
import joptsimple.OptionSpec;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.GetDefaultPortEvent;
|
import net.raphimc.viaproxy.plugins.events.GetDefaultPortEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.PostOptionsParseEvent;
|
import net.raphimc.viaproxy.plugins.events.PostOptionsParseEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.PreOptionsParseEvent;
|
import net.raphimc.viaproxy.plugins.events.PreOptionsParseEvent;
|
||||||
@ -87,7 +86,7 @@ public class Options {
|
|||||||
final OptionSpec<Void> legacyClientPassthrough = parser.acceptsAll(asList("legacy_client_passthrough", "legacy_passthrough"), "Allow <= 1.6.4 clients to connect to the backend server (No protocol translation)");
|
final OptionSpec<Void> legacyClientPassthrough = parser.acceptsAll(asList("legacy_client_passthrough", "legacy_passthrough"), "Allow <= 1.6.4 clients to connect to the backend server (No protocol translation)");
|
||||||
final OptionSpec<Void> playerInfoForwarding = parser.acceptsAll(asList("player_info_forwarding", "pif"), "Enabled BungeeCord player info forwarding");
|
final OptionSpec<Void> playerInfoForwarding = parser.acceptsAll(asList("player_info_forwarding", "pif"), "Enabled BungeeCord player info forwarding");
|
||||||
final OptionSpec<Void> ignorePacketTranslationErrors = parser.acceptsAll(List.of("ignore-packet-translation-errors"), "Enabling this will prevent getting disconnected from the server when a packet translation error occurs and instead only print the error in the console. This may cause issues depending on the type of packet which failed to translate");
|
final OptionSpec<Void> ignorePacketTranslationErrors = parser.acceptsAll(List.of("ignore-packet-translation-errors"), "Enabling this will prevent getting disconnected from the server when a packet translation error occurs and instead only print the error in the console. This may cause issues depending on the type of packet which failed to translate");
|
||||||
PluginManager.EVENT_MANAGER.call(new PreOptionsParseEvent(parser));
|
ViaProxy.EVENT_MANAGER.call(new PreOptionsParseEvent(parser));
|
||||||
|
|
||||||
final OptionSet options;
|
final OptionSet options;
|
||||||
try {
|
try {
|
||||||
@ -109,12 +108,12 @@ public class Options {
|
|||||||
if (options.has(connectPort)) {
|
if (options.has(connectPort)) {
|
||||||
CONNECT_PORT = options.valueOf(connectPort);
|
CONNECT_PORT = options.valueOf(connectPort);
|
||||||
} else {
|
} else {
|
||||||
CONNECT_PORT = PluginManager.EVENT_MANAGER.call(new GetDefaultPortEvent(PROTOCOL_VERSION, 25565)).getDefaultPort();
|
CONNECT_PORT = ViaProxy.EVENT_MANAGER.call(new GetDefaultPortEvent(PROTOCOL_VERSION, 25565)).getDefaultPort();
|
||||||
}
|
}
|
||||||
COMPRESSION_THRESHOLD = options.valueOf(compressionThreshold);
|
COMPRESSION_THRESHOLD = options.valueOf(compressionThreshold);
|
||||||
OPENAUTHMOD_AUTH = options.has(openAuthModAuth);
|
OPENAUTHMOD_AUTH = options.has(openAuthModAuth);
|
||||||
if (options.has(guiAccountIndex)) {
|
if (options.has(guiAccountIndex)) {
|
||||||
final List<Account> accounts = ViaProxy.saveManager.accountsSave.getAccounts();
|
final List<Account> accounts = ViaProxy.getSaveManager().accountsSave.getAccounts();
|
||||||
final int index = options.valueOf(guiAccountIndex);
|
final int index = options.valueOf(guiAccountIndex);
|
||||||
if (index < 0 || index >= accounts.size()) {
|
if (index < 0 || index >= accounts.size()) {
|
||||||
Logger.LOGGER.error("Invalid account index: " + index);
|
Logger.LOGGER.error("Invalid account index: " + index);
|
||||||
@ -150,7 +149,7 @@ public class Options {
|
|||||||
LEGACY_CLIENT_PASSTHROUGH = options.has(legacyClientPassthrough);
|
LEGACY_CLIENT_PASSTHROUGH = options.has(legacyClientPassthrough);
|
||||||
PLAYER_INFO_FORWARDING = options.has(playerInfoForwarding);
|
PLAYER_INFO_FORWARDING = options.has(playerInfoForwarding);
|
||||||
IGNORE_PACKET_TRANSLATION_ERRORS = options.has(ignorePacketTranslationErrors);
|
IGNORE_PACKET_TRANSLATION_ERRORS = options.has(ignorePacketTranslationErrors);
|
||||||
PluginManager.EVENT_MANAGER.call(new PostOptionsParseEvent(options));
|
ViaProxy.EVENT_MANAGER.call(new PostOptionsParseEvent(options));
|
||||||
} catch (OptionException e) {
|
} catch (OptionException e) {
|
||||||
Logger.LOGGER.error("Error parsing options: " + e.getMessage());
|
Logger.LOGGER.error("Error parsing options: " + e.getMessage());
|
||||||
parser.formatHelpWith(new BetterHelpFormatter());
|
parser.formatHelpWith(new BetterHelpFormatter());
|
||||||
|
@ -23,8 +23,6 @@ import net.lenni0451.classtransform.additionalclassprovider.GuavaClassPathProvid
|
|||||||
import net.lenni0451.classtransform.additionalclassprovider.LazyFileClassProvider;
|
import net.lenni0451.classtransform.additionalclassprovider.LazyFileClassProvider;
|
||||||
import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
||||||
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
||||||
import net.lenni0451.lambdaevents.LambdaManager;
|
|
||||||
import net.lenni0451.lambdaevents.generator.LambdaMetaFactoryGenerator;
|
|
||||||
import net.lenni0451.reflect.stream.RStream;
|
import net.lenni0451.reflect.stream.RStream;
|
||||||
import net.raphimc.javadowngrader.impl.classtransform.JavaDowngraderTransformer;
|
import net.raphimc.javadowngrader.impl.classtransform.JavaDowngraderTransformer;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
@ -41,19 +39,22 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class PluginManager {
|
public class PluginManager {
|
||||||
|
|
||||||
public static final LambdaManager EVENT_MANAGER = LambdaManager.threadSafe(new LambdaMetaFactoryGenerator());
|
|
||||||
public static final File PLUGINS_DIR = new File("plugins");
|
public static final File PLUGINS_DIR = new File("plugins");
|
||||||
|
|
||||||
private static final Yaml YAML = new Yaml();
|
private final Yaml yaml = new Yaml();
|
||||||
private static final IClassProvider ROOT_CLASS_PROVIDER = new GuavaClassPathProvider();
|
private final IClassProvider rootClassProvider = new GuavaClassPathProvider();
|
||||||
private static final List<ViaProxyPlugin> PLUGINS = new ArrayList<>();
|
private final List<ViaProxyPlugin> plugins = new ArrayList<>();
|
||||||
|
|
||||||
public static List<ViaProxyPlugin> getPlugins() {
|
public PluginManager() {
|
||||||
return Collections.unmodifiableList(PLUGINS);
|
this.loadPlugins();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViaProxyPlugin getPlugin(String name) {
|
public List<ViaProxyPlugin> getPlugins() {
|
||||||
for (ViaProxyPlugin plugin : PLUGINS) {
|
return Collections.unmodifiableList(this.plugins);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViaProxyPlugin getPlugin(String name) {
|
||||||
|
for (ViaProxyPlugin plugin : this.plugins) {
|
||||||
if (plugin.getName().equalsIgnoreCase(name)) {
|
if (plugin.getName().equalsIgnoreCase(name)) {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
@ -62,7 +63,7 @@ public class PluginManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadPlugins() {
|
private void loadPlugins() {
|
||||||
if (!PLUGINS_DIR.exists() || !PLUGINS_DIR.isDirectory()) {
|
if (!PLUGINS_DIR.exists() || !PLUGINS_DIR.isDirectory()) {
|
||||||
if (!PLUGINS_DIR.mkdirs()) {
|
if (!PLUGINS_DIR.mkdirs()) {
|
||||||
return;
|
return;
|
||||||
@ -81,21 +82,21 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ViaProxyPlugin plugin : PLUGINS) {
|
for (ViaProxyPlugin plugin : this.plugins) {
|
||||||
if (!plugin.isEnabled()) {
|
if (!plugin.isEnabled()) {
|
||||||
enablePlugin(plugin);
|
enablePlugin(plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAndScanJar(final File file) throws Throwable {
|
private void loadAndScanJar(final File file) throws Throwable {
|
||||||
final URL url = file.toURI().toURL();
|
final URL url = file.toURI().toURL();
|
||||||
final TransformerManager transformerManager = new TransformerManager(new LazyFileClassProvider(Collections.singletonList(file), ROOT_CLASS_PROVIDER));
|
final TransformerManager transformerManager = new TransformerManager(new LazyFileClassProvider(Collections.singletonList(file), this.rootClassProvider));
|
||||||
transformerManager.addBytecodeTransformer(new JavaDowngraderTransformer(transformerManager));
|
transformerManager.addBytecodeTransformer(new JavaDowngraderTransformer(transformerManager));
|
||||||
final InjectionClassLoader loader = new InjectionClassLoader(transformerManager, PluginManager.class.getClassLoader(), url);
|
final InjectionClassLoader loader = new InjectionClassLoader(transformerManager, PluginManager.class.getClassLoader(), url);
|
||||||
final InputStream viaproxyYml = loader.getResourceAsStream("viaproxy.yml");
|
final InputStream viaproxyYml = loader.getResourceAsStream("viaproxy.yml");
|
||||||
if (viaproxyYml == null) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a viaproxy.yml");
|
if (viaproxyYml == null) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a viaproxy.yml");
|
||||||
final Map<String, Object> yaml = YAML.load(viaproxyYml);
|
final Map<String, Object> yaml = this.yaml.load(viaproxyYml);
|
||||||
if (!yaml.containsKey("name")) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a name attribute in the viaproxy.yml");
|
if (!yaml.containsKey("name")) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a name attribute in the viaproxy.yml");
|
||||||
if (!yaml.containsKey("author")) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a author attribute in the viaproxy.yml");
|
if (!yaml.containsKey("author")) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a author attribute in the viaproxy.yml");
|
||||||
if (!yaml.containsKey("version")) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a version attribute in the viaproxy.yml");
|
if (!yaml.containsKey("version")) throw new IllegalStateException("Plugin '" + file.getName() + "' does not have a version attribute in the viaproxy.yml");
|
||||||
@ -122,10 +123,10 @@ public class PluginManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.LOGGER.info("Loaded plugin '" + plugin.getName() + "' by " + plugin.getAuthor() + " (v" + plugin.getVersion() + ")");
|
Logger.LOGGER.info("Loaded plugin '" + plugin.getName() + "' by " + plugin.getAuthor() + " (v" + plugin.getVersion() + ")");
|
||||||
PLUGINS.add(plugin);
|
this.plugins.add(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void enablePlugin(final ViaProxyPlugin plugin) {
|
private void enablePlugin(final ViaProxyPlugin plugin) {
|
||||||
for (String depend : plugin.getDepends()) {
|
for (String depend : plugin.getDepends()) {
|
||||||
final ViaProxyPlugin dependPlugin = getPlugin(depend);
|
final ViaProxyPlugin dependPlugin = getPlugin(depend);
|
||||||
if (dependPlugin == null) {
|
if (dependPlugin == null) {
|
||||||
|
@ -22,7 +22,7 @@ import net.raphimc.vialoader.impl.platform.ViaAprilFoolsPlatformImpl;
|
|||||||
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl;
|
||||||
import net.raphimc.vialoader.impl.platform.ViaBedrockPlatformImpl;
|
import net.raphimc.vialoader.impl.platform.ViaBedrockPlatformImpl;
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.plugins.events.ProtocolHackInitEvent;
|
import net.raphimc.viaproxy.plugins.events.ProtocolHackInitEvent;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLLoader;
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLLoader;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaLegacyPlatformImpl;
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaLegacyPlatformImpl;
|
||||||
@ -37,7 +37,7 @@ public class ProtocolHack {
|
|||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
patchConfigs();
|
patchConfigs();
|
||||||
final Supplier<?>[] platformSuppliers = PluginManager.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaProxyViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]);
|
final Supplier<?>[] platformSuppliers = ViaProxy.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaProxyViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]);
|
||||||
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), null, null, platformSuppliers);
|
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), null, null, platformSuppliers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.provider
|
|||||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
||||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||||
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
import net.raphimc.vialoader.impl.viaversion.VLLoader;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.plugins.events.ViaLoadingEvent;
|
import net.raphimc.viaproxy.plugins.events.ViaLoadingEvent;
|
||||||
import net.raphimc.viaproxy.protocolhack.providers.*;
|
import net.raphimc.viaproxy.protocolhack.providers.*;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class ViaProxyVLLoader extends VLLoader {
|
|||||||
Via.getManager().getProviders().use(TransferProvider.class, new ViaProxyTransferProvider());
|
Via.getManager().getProviders().use(TransferProvider.class, new ViaProxyTransferProvider());
|
||||||
|
|
||||||
// ViaProxy plugins
|
// ViaProxy plugins
|
||||||
PluginManager.EVENT_MANAGER.call(new ViaLoadingEvent());
|
ViaProxy.EVENT_MANAGER.call(new ViaLoadingEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import com.viaversion.viaversion.libs.gson.JsonObject;
|
|||||||
import net.raphimc.vialoader.impl.platform.ViaVersionPlatformImpl;
|
import net.raphimc.vialoader.impl.platform.ViaVersionPlatformImpl;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.ConsoleFormatter;
|
import net.raphimc.viaproxy.cli.ConsoleFormatter;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -46,7 +45,7 @@ public class ViaProxyViaVersionPlatformImpl extends ViaVersionPlatformImpl {
|
|||||||
root.addProperty("impl_version", ViaProxy.IMPL_VERSION);
|
root.addProperty("impl_version", ViaProxy.IMPL_VERSION);
|
||||||
|
|
||||||
final JsonArray plugins = new JsonArray();
|
final JsonArray plugins = new JsonArray();
|
||||||
for (ViaProxyPlugin plugin : PluginManager.getPlugins()) {
|
for (ViaProxyPlugin plugin : ViaProxy.getPluginManager().getPlugins()) {
|
||||||
final JsonObject pluginObj = new JsonObject();
|
final JsonObject pluginObj = new JsonObject();
|
||||||
pluginObj.addProperty("name", plugin.getName());
|
pluginObj.addProperty("name", plugin.getName());
|
||||||
pluginObj.addProperty("version", plugin.getVersion());
|
pluginObj.addProperty("version", plugin.getVersion());
|
||||||
|
@ -22,8 +22,8 @@ import io.netty.channel.ChannelHandler;
|
|||||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||||
import net.raphimc.netminecraft.netty.connection.MinecraftChannelInitializer;
|
import net.raphimc.netminecraft.netty.connection.MinecraftChannelInitializer;
|
||||||
import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil;
|
import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil;
|
||||||
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
|
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||||
import net.raphimc.viaproxy.proxy.client2proxy.passthrough.LegacyPassthroughInitialHandler;
|
import net.raphimc.viaproxy.proxy.client2proxy.passthrough.LegacyPassthroughInitialHandler;
|
||||||
@ -40,7 +40,7 @@ public class Client2ProxyChannelInitializer extends MinecraftChannelInitializer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel channel) {
|
protected void initChannel(Channel channel) {
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, channel, false)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, channel, false)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ public class Client2ProxyChannelInitializer extends MinecraftChannelInitializer
|
|||||||
super.initChannel(channel);
|
super.initChannel(channel);
|
||||||
channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(false));
|
channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(false));
|
||||||
|
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel, false)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel, false)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ import net.raphimc.netminecraft.util.ServerAddress;
|
|||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.ConnectEvent;
|
import net.raphimc.viaproxy.plugins.events.ConnectEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.PreConnectEvent;
|
import net.raphimc.viaproxy.plugins.events.PreConnectEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.Proxy2ServerHandlerCreationEvent;
|
import net.raphimc.viaproxy.plugins.events.Proxy2ServerHandlerCreationEvent;
|
||||||
@ -63,7 +62,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
|
|||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
|
|
||||||
this.proxyConnection = new DummyProxyConnection(ctx.channel());
|
this.proxyConnection = new DummyProxyConnection(ctx.channel());
|
||||||
ViaProxy.c2pChannels.add(ctx.channel());
|
ViaProxy.getConnectedClients().add(ctx.channel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -187,7 +186,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
|
|||||||
connectPort = newAddress.getPort();
|
connectPort = newAddress.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
final ResolveSrvEvent resolveSrvEvent = PluginManager.EVENT_MANAGER.call(new ResolveSrvEvent(serverVersion, connectIP, connectPort));
|
final ResolveSrvEvent resolveSrvEvent = ViaProxy.EVENT_MANAGER.call(new ResolveSrvEvent(serverVersion, connectIP, connectPort));
|
||||||
connectIP = resolveSrvEvent.getHost();
|
connectIP = resolveSrvEvent.getHost();
|
||||||
connectPort = resolveSrvEvent.getPort();
|
connectPort = resolveSrvEvent.getPort();
|
||||||
|
|
||||||
@ -199,11 +198,11 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final PreConnectEvent preConnectEvent = new PreConnectEvent(serverAddress, serverVersion, clientVersion, this.proxyConnection.getC2P());
|
final PreConnectEvent preConnectEvent = new PreConnectEvent(serverAddress, serverVersion, clientVersion, this.proxyConnection.getC2P());
|
||||||
if (PluginManager.EVENT_MANAGER.call(preConnectEvent).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(preConnectEvent).isCancelled()) {
|
||||||
this.proxyConnection.kickClient(preConnectEvent.getCancelMessage());
|
this.proxyConnection.kickClient(preConnectEvent.getCancelMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
final Supplier<ChannelHandler> handlerSupplier = () -> PluginManager.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new Proxy2ServerHandler(), false)).getHandler();
|
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new Proxy2ServerHandler(), false)).getHandler();
|
||||||
if (serverVersion.equals(VersionEnum.bedrockLatest)) {
|
if (serverVersion.equals(VersionEnum.bedrockLatest)) {
|
||||||
this.proxyConnection = new BedrockProxyConnection(handlerSupplier, Proxy2ServerChannelInitializer::new, this.proxyConnection.getC2P());
|
this.proxyConnection = new BedrockProxyConnection(handlerSupplier, Proxy2ServerChannelInitializer::new, this.proxyConnection.getC2P());
|
||||||
} else {
|
} else {
|
||||||
@ -225,7 +224,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
|
|||||||
|
|
||||||
ChannelUtil.disableAutoRead(this.proxyConnection.getC2P());
|
ChannelUtil.disableAutoRead(this.proxyConnection.getC2P());
|
||||||
Logger.u_info("connect", this.proxyConnection.getC2P().remoteAddress(), this.proxyConnection.getGameProfile(), "[" + clientVersion.getName() + " <-> " + serverVersion.getName() + "] Connecting to " + serverAddress.getAddress() + ":" + serverAddress.getPort());
|
Logger.u_info("connect", this.proxyConnection.getC2P().remoteAddress(), this.proxyConnection.getGameProfile(), "[" + clientVersion.getName() + " <-> " + serverVersion.getName() + "] Connecting to " + serverAddress.getAddress() + ":" + serverAddress.getPort());
|
||||||
PluginManager.EVENT_MANAGER.call(new ConnectEvent(this.proxyConnection));
|
ViaProxy.EVENT_MANAGER.call(new ConnectEvent(this.proxyConnection));
|
||||||
|
|
||||||
this.proxyConnection.connectToServer(serverAddress, serverVersion).addListeners((ThrowingChannelFutureListener) f -> {
|
this.proxyConnection.connectToServer(serverAddress, serverVersion).addListeners((ThrowingChannelFutureListener) f -> {
|
||||||
if (f.isSuccess()) {
|
if (f.isSuccess()) {
|
||||||
|
@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.plugins.events.Client2ProxyHandlerCreationEvent;
|
import net.raphimc.viaproxy.plugins.events.Client2ProxyHandlerCreationEvent;
|
||||||
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
|
import net.raphimc.viaproxy.proxy.util.ExceptionUtil;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ public class LegacyPassthroughInitialHandler extends SimpleChannelInboundHandler
|
|||||||
ctx.pipeline().removeLast();
|
ctx.pipeline().removeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Supplier<ChannelHandler> handlerSupplier = () -> PluginManager.EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new PassthroughClient2ProxyHandler(), true)).getHandler();
|
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new PassthroughClient2ProxyHandler(), true)).getHandler();
|
||||||
final PassthroughClient2ProxyChannelInitializer channelInitializer = new PassthroughClient2ProxyChannelInitializer(handlerSupplier);
|
final PassthroughClient2ProxyChannelInitializer channelInitializer = new PassthroughClient2ProxyChannelInitializer(handlerSupplier);
|
||||||
channelInitializer.initChannel(ctx.channel());
|
channelInitializer.initChannel(ctx.channel());
|
||||||
ctx.channel().pipeline().fireChannelActive();
|
ctx.channel().pipeline().fireChannelActive();
|
||||||
|
@ -20,7 +20,7 @@ package net.raphimc.viaproxy.proxy.client2proxy.passthrough;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
|
import net.raphimc.viaproxy.plugins.events.Client2ProxyChannelInitializeEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
|
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
|
||||||
@ -35,7 +35,7 @@ public class PassthroughClient2ProxyChannelInitializer extends Client2ProxyChann
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel channel) {
|
protected void initChannel(Channel channel) {
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, channel, true)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, channel, true)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ public class PassthroughClient2ProxyChannelInitializer extends Client2ProxyChann
|
|||||||
channel.pipeline().addLast(MCPipeline.FLOW_CONTROL_HANDLER_NAME, MCPipeline.FLOW_CONTROL_HANDLER.get());
|
channel.pipeline().addLast(MCPipeline.FLOW_CONTROL_HANDLER_NAME, MCPipeline.FLOW_CONTROL_HANDLER.get());
|
||||||
channel.pipeline().addLast(MCPipeline.HANDLER_HANDLER_NAME, this.handlerSupplier.get());
|
channel.pipeline().addLast(MCPipeline.HANDLER_HANDLER_NAME, this.handlerSupplier.get());
|
||||||
|
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel, true)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel, true)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import net.raphimc.netminecraft.util.ServerAddress;
|
import net.raphimc.netminecraft.util.ServerAddress;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.Proxy2ServerHandlerCreationEvent;
|
import net.raphimc.viaproxy.plugins.events.Proxy2ServerHandlerCreationEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.ResolveSrvEvent;
|
import net.raphimc.viaproxy.plugins.events.ResolveSrvEvent;
|
||||||
import net.raphimc.viaproxy.proxy.proxy2server.passthrough.PassthroughProxy2ServerChannelInitializer;
|
import net.raphimc.viaproxy.proxy.proxy2server.passthrough.PassthroughProxy2ServerChannelInitializer;
|
||||||
@ -73,14 +73,14 @@ public class PassthroughClient2ProxyHandler extends SimpleChannelInboundHandler<
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void connectToServer(final Channel c2pChannel) {
|
protected void connectToServer(final Channel c2pChannel) {
|
||||||
final Supplier<ChannelHandler> handlerSupplier = () -> PluginManager.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new PassthroughProxy2ServerHandler(), true)).getHandler();
|
final Supplier<ChannelHandler> handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new PassthroughProxy2ServerHandler(), true)).getHandler();
|
||||||
this.proxyConnection = new LegacyProxyConnection(handlerSupplier, PassthroughProxy2ServerChannelInitializer::new, c2pChannel);
|
this.proxyConnection = new LegacyProxyConnection(handlerSupplier, PassthroughProxy2ServerChannelInitializer::new, c2pChannel);
|
||||||
this.proxyConnection.getC2P().attr(LegacyProxyConnection.LEGACY_PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
this.proxyConnection.getC2P().attr(LegacyProxyConnection.LEGACY_PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
||||||
|
|
||||||
final ServerAddress unresolvedAddress = this.getServerAddress();
|
final ServerAddress unresolvedAddress = this.getServerAddress();
|
||||||
final VersionEnum serverVersion = Options.PROTOCOL_VERSION;
|
final VersionEnum serverVersion = Options.PROTOCOL_VERSION;
|
||||||
|
|
||||||
final ResolveSrvEvent resolveSrvEvent = PluginManager.EVENT_MANAGER.call(new ResolveSrvEvent(serverVersion, unresolvedAddress.getAddress(), unresolvedAddress.getPort()));
|
final ResolveSrvEvent resolveSrvEvent = ViaProxy.EVENT_MANAGER.call(new ResolveSrvEvent(serverVersion, unresolvedAddress.getAddress(), unresolvedAddress.getPort()));
|
||||||
final String connectIP = resolveSrvEvent.getHost();
|
final String connectIP = resolveSrvEvent.getHost();
|
||||||
final int connectPort = resolveSrvEvent.getPort();
|
final int connectPort = resolveSrvEvent.getPort();
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ import net.raphimc.viabedrock.protocol.storage.AuthChainData;
|
|||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.FillPlayerDataEvent;
|
import net.raphimc.viaproxy.plugins.events.FillPlayerDataEvent;
|
||||||
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
||||||
import net.raphimc.viaproxy.saves.impl.accounts.Account;
|
import net.raphimc.viaproxy.saves.impl.accounts.Account;
|
||||||
@ -60,7 +59,7 @@ public class ExternalInterface {
|
|||||||
try {
|
try {
|
||||||
if (proxyConnection.getUserOptions().account() != null) {
|
if (proxyConnection.getUserOptions().account() != null) {
|
||||||
final Account account = proxyConnection.getUserOptions().account();
|
final Account account = proxyConnection.getUserOptions().account();
|
||||||
ViaProxy.saveManager.accountsSave.ensureRefreshed(account);
|
ViaProxy.getSaveManager().accountsSave.ensureRefreshed(account);
|
||||||
|
|
||||||
proxyConnection.setGameProfile(account.getGameProfile());
|
proxyConnection.setGameProfile(account.getGameProfile());
|
||||||
final UserConnection user = proxyConnection.getUserConnection();
|
final UserConnection user = proxyConnection.getUserConnection();
|
||||||
@ -93,7 +92,7 @@ public class ExternalInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginManager.EVENT_MANAGER.call(new FillPlayerDataEvent(proxyConnection));
|
ViaProxy.EVENT_MANAGER.call(new FillPlayerDataEvent(proxyConnection));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Logger.LOGGER.error("Failed to fill player data", e);
|
Logger.LOGGER.error("Failed to fill player data", e);
|
||||||
proxyConnection.kickClient("§cFailed to fill player data. This might be caused by outdated account tokens or rate limits. Wait a couple of seconds and try again. If the problem persists, remove and re-add your account.");
|
proxyConnection.kickClient("§cFailed to fill player data. This might be caused by outdated account tokens or rate limits. Wait a couple of seconds and try again. If the problem persists, remove and re-add your account.");
|
||||||
|
@ -29,8 +29,8 @@ import net.raphimc.netminecraft.packet.UnknownPacket;
|
|||||||
import net.raphimc.netminecraft.packet.impl.login.*;
|
import net.raphimc.netminecraft.packet.impl.login.*;
|
||||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent;
|
import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.PreMojangAuthEvent;
|
import net.raphimc.viaproxy.plugins.events.PreMojangAuthEvent;
|
||||||
import net.raphimc.viaproxy.proxy.LoginState;
|
import net.raphimc.viaproxy.proxy.LoginState;
|
||||||
@ -95,7 +95,7 @@ public class LoginPacketHandler extends PacketHandler {
|
|||||||
if (Options.ONLINE_MODE) {
|
if (Options.ONLINE_MODE) {
|
||||||
this.proxyConnection.getC2P().writeAndFlush(new S2CLoginKeyPacket1_8("", KEY_PAIR.getPublic().getEncoded(), this.verifyToken)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
this.proxyConnection.getC2P().writeAndFlush(new S2CLoginKeyPacket1_8("", KEY_PAIR.getPublic().getEncoded(), this.verifyToken)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
} else {
|
} else {
|
||||||
PluginManager.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection));
|
ViaProxy.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection));
|
||||||
ExternalInterface.fillPlayerData(this.proxyConnection);
|
ExternalInterface.fillPlayerData(this.proxyConnection);
|
||||||
this.proxyConnection.getChannel().writeAndFlush(this.proxyConnection.getLoginHelloPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
this.proxyConnection.getChannel().writeAndFlush(this.proxyConnection.getLoginHelloPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ public class LoginPacketHandler extends PacketHandler {
|
|||||||
final SecretKey secretKey = CryptUtil.decryptSecretKey(KEY_PAIR.getPrivate(), loginKeyPacket.encryptedSecretKey);
|
final SecretKey secretKey = CryptUtil.decryptSecretKey(KEY_PAIR.getPrivate(), loginKeyPacket.encryptedSecretKey);
|
||||||
this.proxyConnection.getC2P().attr(MCPipeline.ENCRYPTION_ATTRIBUTE_KEY).set(new AESEncryption(secretKey));
|
this.proxyConnection.getC2P().attr(MCPipeline.ENCRYPTION_ATTRIBUTE_KEY).set(new AESEncryption(secretKey));
|
||||||
|
|
||||||
if (!PluginManager.EVENT_MANAGER.call(new PreMojangAuthEvent(this.proxyConnection)).isCancelled()) {
|
if (!ViaProxy.EVENT_MANAGER.call(new PreMojangAuthEvent(this.proxyConnection)).isCancelled()) {
|
||||||
final String userName = this.proxyConnection.getGameProfile().getName();
|
final String userName = this.proxyConnection.getGameProfile().getName();
|
||||||
try {
|
try {
|
||||||
final String serverHash = new BigInteger(CryptUtil.computeServerIdHash("", KEY_PAIR.getPublic(), secretKey)).toString(16);
|
final String serverHash = new BigInteger(CryptUtil.computeServerIdHash("", KEY_PAIR.getPublic(), secretKey)).toString(16);
|
||||||
@ -139,7 +139,7 @@ public class LoginPacketHandler extends PacketHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginManager.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection));
|
ViaProxy.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection));
|
||||||
ExternalInterface.fillPlayerData(this.proxyConnection);
|
ExternalInterface.fillPlayerData(this.proxyConnection);
|
||||||
this.proxyConnection.getChannel().writeAndFlush(this.proxyConnection.getLoginHelloPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
this.proxyConnection.getChannel().writeAndFlush(this.proxyConnection.getLoginHelloPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ import net.raphimc.netminecraft.netty.connection.MinecraftChannelInitializer;
|
|||||||
import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil;
|
import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil;
|
||||||
import net.raphimc.vialoader.netty.VLPipeline;
|
import net.raphimc.vialoader.netty.VLPipeline;
|
||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.Proxy2ServerChannelInitializeEvent;
|
import net.raphimc.viaproxy.plugins.events.Proxy2ServerChannelInitializeEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLPipeline;
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLPipeline;
|
||||||
@ -56,7 +56,7 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel channel) {
|
protected void initChannel(Channel channel) {
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, channel, false)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, channel, false)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -80,7 +80,7 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer
|
|||||||
channel.pipeline().addLast(new ViaProxyVLPipeline(user, proxyConnection.getServerVersion()));
|
channel.pipeline().addLast(new ViaProxyVLPipeline(user, proxyConnection.getServerVersion()));
|
||||||
channel.pipeline().addAfter(VLPipeline.VIA_CODEC_NAME, "via-" + MCPipeline.FLOW_CONTROL_HANDLER_NAME, new NoReadFlowControlHandler());
|
channel.pipeline().addAfter(VLPipeline.VIA_CODEC_NAME, "via-" + MCPipeline.FLOW_CONTROL_HANDLER_NAME, new NoReadFlowControlHandler());
|
||||||
|
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, channel, false)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, channel, false)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ import io.netty.channel.Channel;
|
|||||||
import io.netty.channel.ChannelHandler;
|
import io.netty.channel.ChannelHandler;
|
||||||
import io.netty.handler.codec.haproxy.HAProxyMessageEncoder;
|
import io.netty.handler.codec.haproxy.HAProxyMessageEncoder;
|
||||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||||
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.Proxy2ServerChannelInitializeEvent;
|
import net.raphimc.viaproxy.plugins.events.Proxy2ServerChannelInitializeEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||||
import net.raphimc.viaproxy.proxy.proxy2server.Proxy2ServerChannelInitializer;
|
import net.raphimc.viaproxy.proxy.proxy2server.Proxy2ServerChannelInitializer;
|
||||||
@ -37,7 +37,7 @@ public class PassthroughProxy2ServerChannelInitializer extends Proxy2ServerChann
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initChannel(Channel channel) {
|
protected void initChannel(Channel channel) {
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, channel, true)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, channel, true)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public class PassthroughProxy2ServerChannelInitializer extends Proxy2ServerChann
|
|||||||
|
|
||||||
channel.pipeline().addLast(MCPipeline.HANDLER_HANDLER_NAME, this.handlerSupplier.get());
|
channel.pipeline().addLast(MCPipeline.HANDLER_HANDLER_NAME, this.handlerSupplier.get());
|
||||||
|
|
||||||
if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, channel, true)).isCancelled()) {
|
if (ViaProxy.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, channel, true)).isCancelled()) {
|
||||||
channel.close();
|
channel.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class NewAccountsSave extends AbstractSave {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
|
try (final CloseableHttpClient httpClient = MicrosoftConstants.createHttpClient()) {
|
||||||
if (account.refresh(httpClient)) {
|
if (account.refresh(httpClient)) {
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,26 +95,26 @@ public class UpdateCheckTask implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void showUpdateWarning(final String latestVersion) {
|
private void showUpdateWarning(final String latestVersion) {
|
||||||
JOptionPane.showMessageDialog(ViaProxy.ui, I18n.get("popup.update.info", VERSION, latestVersion), "ViaProxy", JOptionPane.WARNING_MESSAGE);
|
JOptionPane.showMessageDialog(ViaProxy.getUI(), I18n.get("popup.update.info", VERSION, latestVersion), "ViaProxy", JOptionPane.WARNING_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showUpdateQuestion(final String name, final String downloadUrl, final String latestVersion) {
|
private void showUpdateQuestion(final String name, final String downloadUrl, final String latestVersion) {
|
||||||
int chosen = JOptionPane.showConfirmDialog(ViaProxy.ui, I18n.get("popup.update.info", VERSION, latestVersion) + "\n\n" + I18n.get("popup.update.question"), "ViaProxy", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
int chosen = JOptionPane.showConfirmDialog(ViaProxy.getUI(), I18n.get("popup.update.info", VERSION, latestVersion) + "\n\n" + I18n.get("popup.update.question"), "ViaProxy", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||||
if (chosen == JOptionPane.YES_OPTION) {
|
if (chosen == JOptionPane.YES_OPTION) {
|
||||||
File f = new File(name);
|
File f = new File(name);
|
||||||
new DownloadPopup(ViaProxy.ui, downloadUrl, f, () -> SwingUtilities.invokeLater(() -> {
|
new DownloadPopup(ViaProxy.getUI(), downloadUrl, f, () -> SwingUtilities.invokeLater(() -> {
|
||||||
JOptionPane.showMessageDialog(ViaProxy.ui, I18n.get("popup.update.success"), "ViaProxy", JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane.showMessageDialog(ViaProxy.getUI(), I18n.get("popup.update.success"), "ViaProxy", JOptionPane.INFORMATION_MESSAGE);
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(new String[]{System.getProperty("java.home") + "/bin/java", "-jar", f.getAbsolutePath()});
|
Runtime.getRuntime().exec(new String[]{System.getProperty("java.home") + "/bin/java", "-jar", f.getAbsolutePath()});
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.LOGGER.error("Could not start the new ViaProxy jar", e);
|
Logger.LOGGER.error("Could not start the new ViaProxy jar", e);
|
||||||
ViaProxy.ui.showException(e);
|
ViaProxy.getUI().showException(e);
|
||||||
}
|
}
|
||||||
}), t -> {
|
}), t -> {
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
Logger.LOGGER.error("Could not download the latest version of ViaProxy", t);
|
Logger.LOGGER.error("Could not download the latest version of ViaProxy", t);
|
||||||
ViaProxy.ui.showException(t);
|
ViaProxy.getUI().showException(t);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class I18n {
|
|||||||
private static String currentLocale;
|
private static String currentLocale;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (ViaProxy.saveManager == null) {
|
if (ViaProxy.getSaveManager() == null) {
|
||||||
throw new IllegalStateException("ViaProxy is not yet initialized");
|
throw new IllegalStateException("ViaProxy is not yet initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class I18n {
|
|||||||
throw new RuntimeException("Failed to load translations", e);
|
throw new RuntimeException("Failed to load translations", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLocale = ViaProxy.saveManager.uiSave.get("locale");
|
currentLocale = ViaProxy.getSaveManager().uiSave.get("locale");
|
||||||
if (currentLocale == null || !LOCALES.containsKey(currentLocale)) {
|
if (currentLocale == null || !LOCALES.containsKey(currentLocale)) {
|
||||||
final String systemLocale = Locale.getDefault().getLanguage() + '_' + Locale.getDefault().getCountry();
|
final String systemLocale = Locale.getDefault().getLanguage() + '_' + Locale.getDefault().getCountry();
|
||||||
if (LOCALES.containsKey(systemLocale)) {
|
if (LOCALES.containsKey(systemLocale)) {
|
||||||
@ -98,13 +98,13 @@ public class I18n {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setLocale(final String locale) {
|
public static void setLocale(final String locale) {
|
||||||
if (ViaProxy.saveManager == null) {
|
if (ViaProxy.getSaveManager() == null) {
|
||||||
throw new IllegalStateException("ViaProxy is not yet initialized");
|
throw new IllegalStateException("ViaProxy is not yet initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
currentLocale = locale;
|
currentLocale = locale;
|
||||||
ViaProxy.saveManager.uiSave.put("locale", locale);
|
ViaProxy.getSaveManager().uiSave.put("locale", locale);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<String> getAvailableLocales() {
|
public static Collection<String> getAvailableLocales() {
|
||||||
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ViaProxyUI extends JFrame {
|
public class ViaProxyUI extends JFrame {
|
||||||
|
|
||||||
public static final LambdaManager EVENT_MANAGER = LambdaManager.threadSafe(new LambdaMetaFactoryGenerator(JavaBypass.TRUSTED_LOOKUP));
|
public final LambdaManager eventManager = LambdaManager.threadSafe(new LambdaMetaFactoryGenerator(JavaBypass.TRUSTED_LOOKUP));
|
||||||
|
|
||||||
public static final int BORDER_PADDING = 10;
|
public static final int BORDER_PADDING = 10;
|
||||||
public static final int BODY_BLOCK_PADDING = 10;
|
public static final int BODY_BLOCK_PADDING = 10;
|
||||||
@ -59,7 +59,7 @@ public class ViaProxyUI extends JFrame {
|
|||||||
|
|
||||||
public ViaProxyUI() {
|
public ViaProxyUI() {
|
||||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> this.showException(e));
|
Thread.setDefaultUncaughtExceptionHandler((t, e) -> this.showException(e));
|
||||||
EVENT_MANAGER.register(this);
|
this.eventManager.register(this);
|
||||||
|
|
||||||
this.setLookAndFeel();
|
this.setLookAndFeel();
|
||||||
this.loadIcons();
|
this.loadIcons();
|
||||||
@ -94,7 +94,7 @@ public class ViaProxyUI extends JFrame {
|
|||||||
this.addWindowListener(new WindowAdapter() {
|
this.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e) {
|
public void windowClosing(WindowEvent e) {
|
||||||
EVENT_MANAGER.call(new UICloseEvent());
|
ViaProxyUI.this.eventManager.call(new UICloseEvent());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setSize(500, 360);
|
this.setSize(500, 360);
|
||||||
@ -112,7 +112,7 @@ public class ViaProxyUI extends JFrame {
|
|||||||
final AUITab tab = field.get();
|
final AUITab tab = field.get();
|
||||||
this.tabs.add(field.get());
|
this.tabs.add(field.get());
|
||||||
tab.add(this.contentPane);
|
tab.add(this.contentPane);
|
||||||
EVENT_MANAGER.register(tab);
|
this.eventManager.register(tab);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.contentPane.setEnabledAt(this.contentPane.indexOfTab(this.accountsTab.getName()), false);
|
this.contentPane.setEnabledAt(this.contentPane.indexOfTab(this.accountsTab.getName()), false);
|
||||||
|
@ -128,8 +128,8 @@ public class AccountsTab extends AUITab {
|
|||||||
int index = this.accountsList.getSelectedIndex();
|
int index = this.accountsList.getSelectedIndex();
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
Account removed = model.remove(index);
|
Account removed = model.remove(index);
|
||||||
ViaProxy.saveManager.accountsSave.removeAccount(removed);
|
ViaProxy.getSaveManager().accountsSave.removeAccount(removed);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
if (Options.MC_ACCOUNT == removed) {
|
if (Options.MC_ACCOUNT == removed) {
|
||||||
if (model.isEmpty()) this.markSelected(-1);
|
if (model.isEmpty()) this.markSelected(-1);
|
||||||
else this.markSelected(0);
|
else this.markSelected(0);
|
||||||
@ -168,8 +168,8 @@ public class AccountsTab extends AUITab {
|
|||||||
addOfflineAccountButton.addActionListener(event -> {
|
addOfflineAccountButton.addActionListener(event -> {
|
||||||
String username = JOptionPane.showInputDialog(this.frame, I18n.get("tab.accounts.add_offline.enter_username"), I18n.get("tab.accounts.add.title"), JOptionPane.PLAIN_MESSAGE);
|
String username = JOptionPane.showInputDialog(this.frame, I18n.get("tab.accounts.add_offline.enter_username"), I18n.get("tab.accounts.add.title"), JOptionPane.PLAIN_MESSAGE);
|
||||||
if (username != null && !username.trim().isEmpty()) {
|
if (username != null && !username.trim().isEmpty()) {
|
||||||
Account account = ViaProxy.saveManager.accountsSave.addAccount(username);
|
Account account = ViaProxy.getSaveManager().accountsSave.addAccount(username);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
this.addAccount(account);
|
this.addAccount(account);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -214,7 +214,7 @@ public class AccountsTab extends AUITab {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onInit(final UIInitEvent event) {
|
private void onInit(final UIInitEvent event) {
|
||||||
ViaProxy.saveManager.accountsSave.getAccounts().forEach(this::addAccount);
|
ViaProxy.getSaveManager().accountsSave.getAccounts().forEach(this::addAccount);
|
||||||
DefaultListModel<Account> model = (DefaultListModel<Account>) this.accountsList.getModel();
|
DefaultListModel<Account> model = (DefaultListModel<Account>) this.accountsList.getModel();
|
||||||
if (!model.isEmpty()) this.markSelected(0);
|
if (!model.isEmpty()) this.markSelected(0);
|
||||||
}
|
}
|
||||||
@ -239,7 +239,7 @@ public class AccountsTab extends AUITab {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Options.MC_ACCOUNT = ViaProxy.saveManager.accountsSave.getAccounts().get(index);
|
Options.MC_ACCOUNT = ViaProxy.getSaveManager().accountsSave.getAccounts().get(index);
|
||||||
this.accountsList.repaint();
|
this.accountsList.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,9 +252,9 @@ public class AccountsTab extends AUITab {
|
|||||||
model.add(index - 1, account);
|
model.add(index - 1, account);
|
||||||
this.accountsList.setSelectedIndex(index - 1);
|
this.accountsList.setSelectedIndex(index - 1);
|
||||||
|
|
||||||
ViaProxy.saveManager.accountsSave.removeAccount(account);
|
ViaProxy.getSaveManager().accountsSave.removeAccount(account);
|
||||||
ViaProxy.saveManager.accountsSave.addAccount(index - 1, account);
|
ViaProxy.getSaveManager().accountsSave.addAccount(index - 1, account);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveDown(final int index) {
|
private void moveDown(final int index) {
|
||||||
@ -266,9 +266,9 @@ public class AccountsTab extends AUITab {
|
|||||||
model.add(index + 1, account);
|
model.add(index + 1, account);
|
||||||
this.accountsList.setSelectedIndex(index + 1);
|
this.accountsList.setSelectedIndex(index + 1);
|
||||||
|
|
||||||
ViaProxy.saveManager.accountsSave.removeAccount(account);
|
ViaProxy.getSaveManager().accountsSave.removeAccount(account);
|
||||||
ViaProxy.saveManager.accountsSave.addAccount(index + 1, account);
|
ViaProxy.getSaveManager().accountsSave.addAccount(index + 1, account);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleLogin(final TFunction<Consumer<StepMsaDeviceCode.MsaDeviceCode>, Account> requestHandler) {
|
private void handleLogin(final TFunction<Consumer<StepMsaDeviceCode.MsaDeviceCode>, Account> requestHandler) {
|
||||||
@ -280,8 +280,8 @@ public class AccountsTab extends AUITab {
|
|||||||
})));
|
})));
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
this.closePopup();
|
this.closePopup();
|
||||||
ViaProxy.saveManager.accountsSave.addAccount(account);
|
ViaProxy.getSaveManager().accountsSave.addAccount(account);
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
this.addAccount(account);
|
this.addAccount(account);
|
||||||
this.frame.showInfo(I18n.get("tab.accounts.add.success", account.getName()));
|
this.frame.showInfo(I18n.get("tab.accounts.add.success", account.getName()));
|
||||||
});
|
});
|
||||||
|
@ -77,7 +77,7 @@ public class AdvancedTab extends AUITab {
|
|||||||
|
|
||||||
this.bindPort = new JSpinner(new SpinnerNumberModel(25568, 1, 65535, 1));
|
this.bindPort = new JSpinner(new SpinnerNumberModel(25568, 1, 65535, 1));
|
||||||
this.bindPort.setToolTipText(I18n.get("tab.advanced.bind_port.tooltip"));
|
this.bindPort.setToolTipText(I18n.get("tab.advanced.bind_port.tooltip"));
|
||||||
ViaProxy.saveManager.uiSave.loadSpinner("bind_port", this.bindPort);
|
ViaProxy.getSaveManager().uiSave.loadSpinner("bind_port", this.bindPort);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.bindPort);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.bindPort);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -87,33 +87,33 @@ public class AdvancedTab extends AUITab {
|
|||||||
|
|
||||||
this.proxy = new JTextField();
|
this.proxy = new JTextField();
|
||||||
this.proxy.setToolTipText(I18n.get("tab.advanced.proxy_url.tooltip"));
|
this.proxy.setToolTipText(I18n.get("tab.advanced.proxy_url.tooltip"));
|
||||||
ViaProxy.saveManager.uiSave.loadTextField("proxy", this.proxy);
|
ViaProxy.getSaveManager().uiSave.loadTextField("proxy", this.proxy);
|
||||||
GBC.create(body).grid(0, gridy++).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.proxy);
|
GBC.create(body).grid(0, gridy++).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.proxy);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.proxyOnlineMode = new JCheckBox(I18n.get("tab.advanced.proxy_online_mode.label"));
|
this.proxyOnlineMode = new JCheckBox(I18n.get("tab.advanced.proxy_online_mode.label"));
|
||||||
this.proxyOnlineMode.setToolTipText(I18n.get("tab.advanced.proxy_online_mode.tooltip"));
|
this.proxyOnlineMode.setToolTipText(I18n.get("tab.advanced.proxy_online_mode.tooltip"));
|
||||||
ViaProxy.saveManager.uiSave.loadCheckBox("proxy_online_mode", this.proxyOnlineMode);
|
ViaProxy.getSaveManager().uiSave.loadCheckBox("proxy_online_mode", this.proxyOnlineMode);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.proxyOnlineMode);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.proxyOnlineMode);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.legacySkinLoading = new JCheckBox(I18n.get("tab.advanced.legacy_skin_loading.label"));
|
this.legacySkinLoading = new JCheckBox(I18n.get("tab.advanced.legacy_skin_loading.label"));
|
||||||
this.legacySkinLoading.setToolTipText(I18n.get("tab.advanced.legacy_skin_loading.tooltip"));
|
this.legacySkinLoading.setToolTipText(I18n.get("tab.advanced.legacy_skin_loading.tooltip"));
|
||||||
ViaProxy.saveManager.uiSave.loadCheckBox("legacy_skin_loading", this.legacySkinLoading);
|
ViaProxy.getSaveManager().uiSave.loadCheckBox("legacy_skin_loading", this.legacySkinLoading);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).fill(GridBagConstraints.HORIZONTAL).add(this.legacySkinLoading);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).fill(GridBagConstraints.HORIZONTAL).add(this.legacySkinLoading);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.chatSigning = new JCheckBox(I18n.get("tab.advanced.chat_signing.label"));
|
this.chatSigning = new JCheckBox(I18n.get("tab.advanced.chat_signing.label"));
|
||||||
this.chatSigning.setToolTipText(I18n.get("tab.advanced.chat_signing.tooltip"));
|
this.chatSigning.setToolTipText(I18n.get("tab.advanced.chat_signing.tooltip"));
|
||||||
this.chatSigning.setSelected(true);
|
this.chatSigning.setSelected(true);
|
||||||
ViaProxy.saveManager.uiSave.loadCheckBox("chat_signing", this.chatSigning);
|
ViaProxy.getSaveManager().uiSave.loadCheckBox("chat_signing", this.chatSigning);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.chatSigning);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.chatSigning);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.ignorePacketTranslationErrors = new JCheckBox(I18n.get("tab.advanced.ignore_packet_translation_errors.label"));
|
this.ignorePacketTranslationErrors = new JCheckBox(I18n.get("tab.advanced.ignore_packet_translation_errors.label"));
|
||||||
this.ignorePacketTranslationErrors.setToolTipText(I18n.get("tab.advanced.ignore_packet_translation_errors.tooltip"));
|
this.ignorePacketTranslationErrors.setToolTipText(I18n.get("tab.advanced.ignore_packet_translation_errors.tooltip"));
|
||||||
this.ignorePacketTranslationErrors.setSelected(false);
|
this.ignorePacketTranslationErrors.setSelected(false);
|
||||||
ViaProxy.saveManager.uiSave.loadCheckBox("ignore_packet_translation_errors", this.ignorePacketTranslationErrors);
|
ViaProxy.getSaveManager().uiSave.loadCheckBox("ignore_packet_translation_errors", this.ignorePacketTranslationErrors);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).fill(GridBagConstraints.HORIZONTAL).add(this.ignorePacketTranslationErrors);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).fill(GridBagConstraints.HORIZONTAL).add(this.ignorePacketTranslationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,12 +131,12 @@ public class AdvancedTab extends AUITab {
|
|||||||
DumpUtil.postDump(null).whenComplete((url, e) -> {
|
DumpUtil.postDump(null).whenComplete((url, e) -> {
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
Logger.LOGGER.error("Failed to create ViaVersion dump", e);
|
Logger.LOGGER.error("Failed to create ViaVersion dump", e);
|
||||||
SwingUtilities.invokeLater(() -> ViaProxy.ui.showError(e.getMessage()));
|
SwingUtilities.invokeLater(() -> ViaProxy.getUI().showError(e.getMessage()));
|
||||||
} else {
|
} else {
|
||||||
ViaProxy.ui.openURL(url);
|
ViaProxy.getUI().openURL(url);
|
||||||
final StringSelection stringSelection = new StringSelection(url);
|
final StringSelection stringSelection = new StringSelection(url);
|
||||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, stringSelection);
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, stringSelection);
|
||||||
SwingUtilities.invokeLater(() -> ViaProxy.ui.showInfo(I18n.get("tab.advanced.create_viaversion_dump.success")));
|
SwingUtilities.invokeLater(() -> ViaProxy.getUI().showInfo(I18n.get("tab.advanced.create_viaversion_dump.success")));
|
||||||
}
|
}
|
||||||
SwingUtilities.invokeLater(() -> this.viaVersionDumpButton.setEnabled(true));
|
SwingUtilities.invokeLater(() -> this.viaVersionDumpButton.setEnabled(true));
|
||||||
});
|
});
|
||||||
@ -157,18 +157,18 @@ public class AdvancedTab extends AUITab {
|
|||||||
final MclogsClient mclogsClient = new MclogsClient("ViaProxy", ViaProxy.VERSION);
|
final MclogsClient mclogsClient = new MclogsClient("ViaProxy", ViaProxy.VERSION);
|
||||||
final UploadLogResponse apiResponse = mclogsClient.uploadLog(logFile.toPath());
|
final UploadLogResponse apiResponse = mclogsClient.uploadLog(logFile.toPath());
|
||||||
if (apiResponse.isSuccess()) {
|
if (apiResponse.isSuccess()) {
|
||||||
ViaProxy.ui.openURL(apiResponse.getUrl());
|
ViaProxy.getUI().openURL(apiResponse.getUrl());
|
||||||
final StringSelection selection = new StringSelection(apiResponse.getUrl());
|
final StringSelection selection = new StringSelection(apiResponse.getUrl());
|
||||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
|
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(selection, selection);
|
||||||
ViaProxy.ui.showInfo("<html>" + I18n.get("tab.advanced.upload_latest_log.success", "<a href=\"\">" + apiResponse.getUrl() + "</a>") + "</html>");
|
ViaProxy.getUI().showInfo("<html>" + I18n.get("tab.advanced.upload_latest_log.success", "<a href=\"\">" + apiResponse.getUrl() + "</a>") + "</html>");
|
||||||
} else {
|
} else {
|
||||||
ViaProxy.ui.showError(I18n.get("tab.advanced.upload_latest_log.error_generic", apiResponse.getError()));
|
ViaProxy.getUI().showError(I18n.get("tab.advanced.upload_latest_log.error_generic", apiResponse.getError()));
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
ViaProxy.ui.showError(I18n.get("tab.advanced.upload_latest_log.error_not_found"));
|
ViaProxy.getUI().showError(I18n.get("tab.advanced.upload_latest_log.error_not_found"));
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Logger.LOGGER.error("Failed to upload log file", e);
|
Logger.LOGGER.error("Failed to upload log file", e);
|
||||||
ViaProxy.ui.showError(I18n.get("tab.advanced.upload_latest_log.error_generic", e.getMessage()));
|
ViaProxy.getUI().showError(I18n.get("tab.advanced.upload_latest_log.error_generic", e.getMessage()));
|
||||||
} finally {
|
} finally {
|
||||||
this.uploadLogsButton.setEnabled(true);
|
this.uploadLogsButton.setEnabled(true);
|
||||||
}
|
}
|
||||||
@ -192,14 +192,14 @@ public class AdvancedTab extends AUITab {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onClose(final UICloseEvent event) {
|
private void onClose(final UICloseEvent event) {
|
||||||
UISave save = ViaProxy.saveManager.uiSave;
|
UISave save = ViaProxy.getSaveManager().uiSave;
|
||||||
save.put("bind_port", String.valueOf(this.bindPort.getValue()));
|
save.put("bind_port", String.valueOf(this.bindPort.getValue()));
|
||||||
save.put("proxy", this.proxy.getText());
|
save.put("proxy", this.proxy.getText());
|
||||||
save.put("proxy_online_mode", String.valueOf(this.proxyOnlineMode.isSelected()));
|
save.put("proxy_online_mode", String.valueOf(this.proxyOnlineMode.isSelected()));
|
||||||
save.put("legacy_skin_loading", String.valueOf(this.legacySkinLoading.isSelected()));
|
save.put("legacy_skin_loading", String.valueOf(this.legacySkinLoading.isSelected()));
|
||||||
save.put("chat_signing", String.valueOf(this.chatSigning.isSelected()));
|
save.put("chat_signing", String.valueOf(this.chatSigning.isSelected()));
|
||||||
save.put("ignore_packet_translation_errors", String.valueOf(this.ignorePacketTranslationErrors.isSelected()));
|
save.put("ignore_packet_translation_errors", String.valueOf(this.ignorePacketTranslationErrors.isSelected()));
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import net.lenni0451.lambdaevents.EventHandler;
|
|||||||
import net.raphimc.vialoader.util.VersionEnum;
|
import net.raphimc.vialoader.util.VersionEnum;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.GetDefaultPortEvent;
|
import net.raphimc.viaproxy.plugins.events.GetDefaultPortEvent;
|
||||||
import net.raphimc.viaproxy.saves.impl.UISave;
|
import net.raphimc.viaproxy.saves.impl.UISave;
|
||||||
import net.raphimc.viaproxy.saves.impl.accounts.OfflineAccount;
|
import net.raphimc.viaproxy.saves.impl.accounts.OfflineAccount;
|
||||||
@ -108,7 +107,7 @@ public class GeneralTab extends AUITab {
|
|||||||
|
|
||||||
this.serverAddress = new JTextField();
|
this.serverAddress = new JTextField();
|
||||||
this.serverAddress.setToolTipText(I18n.get("tab.general.server_address.tooltip"));
|
this.serverAddress.setToolTipText(I18n.get("tab.general.server_address.tooltip"));
|
||||||
ViaProxy.saveManager.uiSave.loadTextField("server_address", this.serverAddress);
|
ViaProxy.getSaveManager().uiSave.loadTextField("server_address", this.serverAddress);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.serverAddress);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.serverAddress);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -135,7 +134,7 @@ public class GeneralTab extends AUITab {
|
|||||||
this.betaCraftAuth.setSelected(false);
|
this.betaCraftAuth.setSelected(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ViaProxy.saveManager.uiSave.loadComboBox("server_version", this.serverVersion);
|
ViaProxy.getSaveManager().uiSave.loadComboBox("server_version", this.serverVersion);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.serverVersion);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.serverVersion);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -143,13 +142,13 @@ public class GeneralTab extends AUITab {
|
|||||||
GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(minecraftAccountLabel);
|
GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(minecraftAccountLabel);
|
||||||
|
|
||||||
this.authMethod = new JComboBox<>(new String[]{I18n.get("tab.general.minecraft_account.option_no_account"), I18n.get("tab.general.minecraft_account.option_select_account"), I18n.get("tab.general.minecraft_account.option_openauthmod")});
|
this.authMethod = new JComboBox<>(new String[]{I18n.get("tab.general.minecraft_account.option_no_account"), I18n.get("tab.general.minecraft_account.option_select_account"), I18n.get("tab.general.minecraft_account.option_openauthmod")});
|
||||||
ViaProxy.saveManager.uiSave.loadComboBox("auth_method", this.authMethod);
|
ViaProxy.getSaveManager().uiSave.loadComboBox("auth_method", this.authMethod);
|
||||||
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.authMethod);
|
GBC.create(body).grid(0, gridy++).weightx(1).insets(0, BORDER_PADDING, 0, BORDER_PADDING).fill(GridBagConstraints.HORIZONTAL).add(this.authMethod);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
this.betaCraftAuth = new JCheckBox(I18n.get("tab.general.betacraft_auth.label"));
|
this.betaCraftAuth = new JCheckBox(I18n.get("tab.general.betacraft_auth.label"));
|
||||||
this.betaCraftAuth.setToolTipText(I18n.get("tab.general.betacraft_auth.tooltip"));
|
this.betaCraftAuth.setToolTipText(I18n.get("tab.general.betacraft_auth.tooltip"));
|
||||||
ViaProxy.saveManager.uiSave.loadCheckBox("betacraft_auth", this.betaCraftAuth);
|
ViaProxy.getSaveManager().uiSave.loadCheckBox("betacraft_auth", this.betaCraftAuth);
|
||||||
GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.betaCraftAuth);
|
GBC.create(body).grid(0, gridy++).insets(BODY_BLOCK_PADDING, BORDER_PADDING, 0, 0).anchor(GridBagConstraints.NORTHWEST).add(this.betaCraftAuth);
|
||||||
// Simulate user action on serverVersion to update betaCraftAuth
|
// Simulate user action on serverVersion to update betaCraftAuth
|
||||||
final ActionEvent fakeAction = new ActionEvent(this.serverVersion, ActionEvent.ACTION_PERFORMED, "");
|
final ActionEvent fakeAction = new ActionEvent(this.serverVersion, ActionEvent.ACTION_PERFORMED, "");
|
||||||
@ -190,30 +189,30 @@ public class GeneralTab extends AUITab {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onClose(final UICloseEvent event) {
|
private void onClose(final UICloseEvent event) {
|
||||||
UISave save = ViaProxy.saveManager.uiSave;
|
UISave save = ViaProxy.getSaveManager().uiSave;
|
||||||
save.put("server_address", this.serverAddress.getText());
|
save.put("server_address", this.serverAddress.getText());
|
||||||
save.put("server_version", String.valueOf(this.serverVersion.getSelectedIndex()));
|
save.put("server_version", String.valueOf(this.serverVersion.getSelectedIndex()));
|
||||||
save.put("auth_method", String.valueOf(this.authMethod.getSelectedIndex()));
|
save.put("auth_method", String.valueOf(this.authMethod.getSelectedIndex()));
|
||||||
save.put("betacraft_auth", String.valueOf(this.betaCraftAuth.isSelected()));
|
save.put("betacraft_auth", String.valueOf(this.betaCraftAuth.isSelected()));
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setComponentsEnabled(final boolean state) {
|
private void setComponentsEnabled(final boolean state) {
|
||||||
this.serverAddress.setEnabled(state);
|
this.serverAddress.setEnabled(state);
|
||||||
this.serverVersion.setEnabled(state);
|
this.serverVersion.setEnabled(state);
|
||||||
ViaProxy.ui.advancedTab.bindPort.setEnabled(state);
|
ViaProxy.getUI().advancedTab.bindPort.setEnabled(state);
|
||||||
this.authMethod.setEnabled(state);
|
this.authMethod.setEnabled(state);
|
||||||
this.betaCraftAuth.setEnabled(state);
|
this.betaCraftAuth.setEnabled(state);
|
||||||
ViaProxy.ui.advancedTab.proxyOnlineMode.setEnabled(state);
|
ViaProxy.getUI().advancedTab.proxyOnlineMode.setEnabled(state);
|
||||||
ViaProxy.ui.advancedTab.proxy.setEnabled(state);
|
ViaProxy.getUI().advancedTab.proxy.setEnabled(state);
|
||||||
ViaProxy.ui.advancedTab.legacySkinLoading.setEnabled(state);
|
ViaProxy.getUI().advancedTab.legacySkinLoading.setEnabled(state);
|
||||||
ViaProxy.ui.advancedTab.chatSigning.setEnabled(state);
|
ViaProxy.getUI().advancedTab.chatSigning.setEnabled(state);
|
||||||
ViaProxy.ui.advancedTab.ignorePacketTranslationErrors.setEnabled(state);
|
ViaProxy.getUI().advancedTab.ignorePacketTranslationErrors.setEnabled(state);
|
||||||
if (state) this.serverVersion.getActionListeners()[0].actionPerformed(null);
|
if (state) this.serverVersion.getActionListeners()[0].actionPerformed(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateStateLabel() {
|
private void updateStateLabel() {
|
||||||
this.stateLabel.setText(I18n.get("tab.general.state.running", "1.7+", "127.0.0.1:" + ViaProxy.ui.advancedTab.bindPort.getValue()));
|
this.stateLabel.setText(I18n.get("tab.general.state.running", "1.7+", "127.0.0.1:" + ViaProxy.getUI().advancedTab.bindPort.getValue()));
|
||||||
this.stateLabel.setForeground(Color.GREEN);
|
this.stateLabel.setForeground(Color.GREEN);
|
||||||
this.stateLabel.setVisible(true);
|
this.stateLabel.setVisible(true);
|
||||||
}
|
}
|
||||||
@ -224,15 +223,15 @@ public class GeneralTab extends AUITab {
|
|||||||
this.frame.showError(I18n.get("tab.general.error.no_server_version_selected"));
|
this.frame.showError(I18n.get("tab.general.error.no_server_version_selected"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ViaProxy.saveManager.uiSave.get("notice.ban_warning") == null) {
|
if (ViaProxy.getSaveManager().uiSave.get("notice.ban_warning") == null) {
|
||||||
ViaProxy.saveManager.uiSave.put("notice.ban_warning", "true");
|
ViaProxy.getSaveManager().uiSave.put("notice.ban_warning", "true");
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
|
|
||||||
this.frame.showWarning("<html><div style='text-align: center;'>" + I18n.get("tab.general.warning.ban_warning.line1") + "<br><b>" + I18n.get("tab.general.warning.risk") + "</b></div></html>");
|
this.frame.showWarning("<html><div style='text-align: center;'>" + I18n.get("tab.general.warning.ban_warning.line1") + "<br><b>" + I18n.get("tab.general.warning.risk") + "</b></div></html>");
|
||||||
}
|
}
|
||||||
if (VersionEnum.bedrockLatest.equals(selectedItem) && ViaProxy.saveManager.uiSave.get("notice.bedrock_warning") == null) {
|
if (VersionEnum.bedrockLatest.equals(selectedItem) && ViaProxy.getSaveManager().uiSave.get("notice.bedrock_warning") == null) {
|
||||||
ViaProxy.saveManager.uiSave.put("notice.bedrock_warning", "true");
|
ViaProxy.getSaveManager().uiSave.put("notice.bedrock_warning", "true");
|
||||||
ViaProxy.saveManager.save();
|
ViaProxy.getSaveManager().save();
|
||||||
|
|
||||||
this.frame.showWarning("<html><div style='text-align: center;'>" + I18n.get("tab.general.warning.bedrock_warning.line1") + "<br><b>" + I18n.get("tab.general.warning.risk") + "</b></div></html>");
|
this.frame.showWarning("<html><div style='text-align: center;'>" + I18n.get("tab.general.warning.bedrock_warning.line1") + "<br><b>" + I18n.get("tab.general.warning.risk") + "</b></div></html>");
|
||||||
}
|
}
|
||||||
@ -244,14 +243,14 @@ public class GeneralTab extends AUITab {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
String serverAddress = this.serverAddress.getText().trim();
|
String serverAddress = this.serverAddress.getText().trim();
|
||||||
final VersionEnum serverVersion = (VersionEnum) this.serverVersion.getSelectedItem();
|
final VersionEnum serverVersion = (VersionEnum) this.serverVersion.getSelectedItem();
|
||||||
final int bindPort = (int) ViaProxy.ui.advancedTab.bindPort.getValue();
|
final int bindPort = (int) ViaProxy.getUI().advancedTab.bindPort.getValue();
|
||||||
final int authMethod = this.authMethod.getSelectedIndex();
|
final int authMethod = this.authMethod.getSelectedIndex();
|
||||||
final boolean betaCraftAuth = this.betaCraftAuth.isSelected();
|
final boolean betaCraftAuth = this.betaCraftAuth.isSelected();
|
||||||
final boolean proxyOnlineMode = ViaProxy.ui.advancedTab.proxyOnlineMode.isSelected();
|
final boolean proxyOnlineMode = ViaProxy.getUI().advancedTab.proxyOnlineMode.isSelected();
|
||||||
final boolean legacySkinLoading = ViaProxy.ui.advancedTab.legacySkinLoading.isSelected();
|
final boolean legacySkinLoading = ViaProxy.getUI().advancedTab.legacySkinLoading.isSelected();
|
||||||
final String proxyUrl = ViaProxy.ui.advancedTab.proxy.getText().trim();
|
final String proxyUrl = ViaProxy.getUI().advancedTab.proxy.getText().trim();
|
||||||
final boolean chatSigning = ViaProxy.ui.advancedTab.chatSigning.isSelected();
|
final boolean chatSigning = ViaProxy.getUI().advancedTab.chatSigning.isSelected();
|
||||||
final boolean ignorePacketTranslationErrors = ViaProxy.ui.advancedTab.ignorePacketTranslationErrors.isSelected();
|
final boolean ignorePacketTranslationErrors = ViaProxy.getUI().advancedTab.ignorePacketTranslationErrors.isSelected();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
@ -278,7 +277,7 @@ public class GeneralTab extends AUITab {
|
|||||||
try {
|
try {
|
||||||
HostAndPort hostAndPort = HostAndPort.fromString(serverAddress);
|
HostAndPort hostAndPort = HostAndPort.fromString(serverAddress);
|
||||||
Options.CONNECT_ADDRESS = hostAndPort.getHost();
|
Options.CONNECT_ADDRESS = hostAndPort.getHost();
|
||||||
Options.CONNECT_PORT = hostAndPort.getPortOrDefault(PluginManager.EVENT_MANAGER.call(new GetDefaultPortEvent(serverVersion, 25565)).getDefaultPort());
|
Options.CONNECT_PORT = hostAndPort.getPortOrDefault(ViaProxy.EVENT_MANAGER.call(new GetDefaultPortEvent(serverVersion, 25565)).getDefaultPort());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
throw new IllegalArgumentException(I18n.get("tab.general.error.invalid_server_address"));
|
throw new IllegalArgumentException(I18n.get("tab.general.error.invalid_server_address"));
|
||||||
}
|
}
|
||||||
|
@ -63,14 +63,14 @@ public class UISettingsTab extends AUITab {
|
|||||||
if (!(language.getSelectedItem() instanceof String locale)) return;
|
if (!(language.getSelectedItem() instanceof String locale)) return;
|
||||||
if (locale.equals(I18n.getCurrentLocale())) return;
|
if (locale.equals(I18n.getCurrentLocale())) return;
|
||||||
I18n.setLocale(locale);
|
I18n.setLocale(locale);
|
||||||
ViaProxy.ui.showInfo(I18n.get("tab.ui_settings.language.success", I18n.get("language.name"), locale));
|
ViaProxy.getUI().showInfo(I18n.get("tab.ui_settings.language.success", I18n.get("language.name"), locale));
|
||||||
try {
|
try {
|
||||||
final File f = new File(ViaProxy.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
final File f = new File(ViaProxy.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||||
Runtime.getRuntime().exec(new String[]{System.getProperty("java.home") + "/bin/java", "-jar", f.getAbsolutePath()});
|
Runtime.getRuntime().exec(new String[]{System.getProperty("java.home") + "/bin/java", "-jar", f.getAbsolutePath()});
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} catch (URISyntaxException | IOException e) {
|
} catch (URISyntaxException | IOException e) {
|
||||||
Logger.LOGGER.error("Could not start the ViaProxy jar", e);
|
Logger.LOGGER.error("Could not start the ViaProxy jar", e);
|
||||||
ViaProxy.ui.showException(e);
|
ViaProxy.getUI().showException(e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user