diff --git a/build.gradle b/build.gradle index b187909..3240ee3 100644 --- a/build.gradle +++ b/build.gradle @@ -95,7 +95,7 @@ dependencies { exclude group: "com.google.code.gson", module: "gson" } include "net.lenni0451.commons:swing:1.6.1" - include("net.raphimc.netminecraft:all:3.0.1") { + include("net.raphimc.netminecraft:all:3.1.0-SNAPSHOT") { exclude group: "com.google.code.gson", module: "gson" } include("net.raphimc:MinecraftAuth:4.1.1") { diff --git a/src/main/java/net/raphimc/viaproxy/ViaProxy.java b/src/main/java/net/raphimc/viaproxy/ViaProxy.java index 527ebd6..dc89933 100644 --- a/src/main/java/net/raphimc/viaproxy/ViaProxy.java +++ b/src/main/java/net/raphimc/viaproxy/ViaProxy.java @@ -260,7 +260,7 @@ public class ViaProxy { } try { Logger.LOGGER.info("Starting proxy server"); - currentProxyServer = new NetServer(() -> EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler(), false)).getHandler(), Client2ProxyChannelInitializer::new); + currentProxyServer = new NetServer(new Client2ProxyChannelInitializer(() -> EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler(), false)).getHandler())); EVENT_MANAGER.call(new ProxyStartEvent()); Logger.LOGGER.info("Binding proxy server to " + AddressUtil.toString(CONFIG.getBindAddress())); currentProxyServer.bind(CONFIG.getBindAddress(), false); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java index 24c410b..09cbc92 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyHandler.java @@ -219,9 +219,9 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler { final Supplier handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new Proxy2ServerHandler(), false)).getHandler(); final ProxyConnection proxyConnection; if (serverVersion.equals(BedrockProtocolVersion.bedrockLatest)) { - proxyConnection = new BedrockProxyConnection(handlerSupplier, Proxy2ServerChannelInitializer::new, this.proxyConnection.getC2P()); + proxyConnection = new BedrockProxyConnection(new Proxy2ServerChannelInitializer(handlerSupplier), this.proxyConnection.getC2P()); } else { - proxyConnection = new ProxyConnection(handlerSupplier, Proxy2ServerChannelInitializer::new, this.proxyConnection.getC2P()); + proxyConnection = new ProxyConnection(new Proxy2ServerChannelInitializer(handlerSupplier), this.proxyConnection.getC2P()); } this.proxyConnection = ViaProxy.EVENT_MANAGER.call(new ProxySessionCreationEvent<>(proxyConnection, false)).getProxySession(); this.proxyConnection.getC2P().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/passthrough/PassthroughClient2ProxyHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/passthrough/PassthroughClient2ProxyHandler.java index 7be42c5..3a18e92 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/passthrough/PassthroughClient2ProxyHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/passthrough/PassthroughClient2ProxyHandler.java @@ -74,7 +74,7 @@ public class PassthroughClient2ProxyHandler extends SimpleChannelInboundHandler< protected void connectToServer(final Channel c2pChannel) { final Supplier handlerSupplier = () -> ViaProxy.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new PassthroughProxy2ServerHandler(), true)).getHandler(); - final LegacyProxyConnection proxyConnection = new LegacyProxyConnection(handlerSupplier, PassthroughProxy2ServerChannelInitializer::new, c2pChannel); + final LegacyProxyConnection proxyConnection = new LegacyProxyConnection(new PassthroughProxy2ServerChannelInitializer(handlerSupplier), c2pChannel); this.proxyConnection = ViaProxy.EVENT_MANAGER.call(new ProxySessionCreationEvent<>(proxyConnection, true)).getProxySession(); this.proxyConnection.getC2P().attr(LegacyProxyConnection.LEGACY_PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/session/BedrockProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/session/BedrockProxyConnection.java index 6236e60..47bc280 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/session/BedrockProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/session/BedrockProxyConnection.java @@ -19,7 +19,10 @@ package net.raphimc.viaproxy.proxy.session; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.*; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; import io.netty.channel.socket.DatagramChannel; import net.lenni0451.reflect.stream.RStream; import net.raphimc.netminecraft.constants.ConnectionState; @@ -35,13 +38,11 @@ import org.cloudburstmc.netty.channel.raknet.config.RakChannelOption; import java.net.InetSocketAddress; import java.net.SocketAddress; import java.util.concurrent.ThreadLocalRandom; -import java.util.function.Function; -import java.util.function.Supplier; public class BedrockProxyConnection extends ProxyConnection { - public BedrockProxyConnection(Supplier handlerSupplier, Function, ChannelInitializer> channelInitializerSupplier, Channel c2p) { - super(handlerSupplier, channelInitializerSupplier, c2p); + public BedrockProxyConnection(final ChannelInitializer channelInitializer, Channel c2p) { + super(channelInitializer, c2p); } @Override @@ -64,7 +65,7 @@ public class BedrockProxyConnection extends ProxyConnection { .option(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L) .option(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong()) .attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY, this) - .handler(this.channelInitializerSupplier.apply(this.handlerSupplier)); + .handler(this.channelInitializer); this.channelFuture = bootstrap.register().syncUninterruptibly(); diff --git a/src/main/java/net/raphimc/viaproxy/proxy/session/DummyProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/session/DummyProxyConnection.java index 7944efa..7c6fa6a 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/session/DummyProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/session/DummyProxyConnection.java @@ -34,7 +34,7 @@ import java.security.Key; public class DummyProxyConnection extends ProxyConnection { public DummyProxyConnection(final Channel c2p) { - super(null, null, c2p); + super(null, c2p); } @Override diff --git a/src/main/java/net/raphimc/viaproxy/proxy/session/LegacyProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/session/LegacyProxyConnection.java index d64a468..a55a50d 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/session/LegacyProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/session/LegacyProxyConnection.java @@ -18,15 +18,16 @@ package net.raphimc.viaproxy.proxy.session; import io.netty.bootstrap.Bootstrap; -import io.netty.channel.*; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; import io.netty.util.AttributeKey; import net.raphimc.netminecraft.netty.connection.NetClient; import net.raphimc.netminecraft.util.ChannelType; import net.raphimc.viaproxy.ViaProxy; import java.net.SocketAddress; -import java.util.function.Function; -import java.util.function.Supplier; public class LegacyProxyConnection extends NetClient { @@ -35,8 +36,8 @@ public class LegacyProxyConnection extends NetClient { private final Channel c2p; private SocketAddress serverAddress; - public LegacyProxyConnection(final Supplier handlerSupplier, final Function, ChannelInitializer> channelInitializerSupplier, final Channel c2p) { - super(handlerSupplier, channelInitializerSupplier); + public LegacyProxyConnection(final ChannelInitializer channelInitializer, final Channel c2p) { + super(channelInitializer); this.c2p = c2p; } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java index b979b23..7a29385 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/session/ProxyConnection.java @@ -48,8 +48,6 @@ import java.security.GeneralSecurityException; import java.security.Key; import java.util.ArrayList; import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; public class ProxyConnection extends NetClient { @@ -74,8 +72,8 @@ public class ProxyConnection extends NetClient { private ConnectionState c2pConnectionState = ConnectionState.HANDSHAKING; private ConnectionState p2sConnectionState = ConnectionState.HANDSHAKING; - public ProxyConnection(final Supplier handlerSupplier, final Function, ChannelInitializer> channelInitializerSupplier, final Channel c2p) { - super(handlerSupplier, channelInitializerSupplier); + public ProxyConnection(final ChannelInitializer channelInitializer, final Channel c2p) { + super(channelInitializer); this.c2p = c2p; }