From 3d15cfca8b57b409a23d7e6a4e3c2954fdabfb5b Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Sat, 28 Jan 2023 19:18:06 +0100 Subject: [PATCH] Updated NetMinecraft --- build.gradle | 2 +- .../Client2ProxyChannelInitializeEvent.java | 8 ++--- .../Proxy2ServerChannelInitializeEvent.java | 8 ++--- .../viaproxy/proxy/ProxyConnection.java | 2 +- .../Client2ProxyChannelInitializer.java | 16 +++++----- .../Proxy2ServerChannelInitializer.java | 30 +++++++++---------- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build.gradle b/build.gradle index 080bc45..b00491f 100644 --- a/build.gradle +++ b/build.gradle @@ -86,7 +86,7 @@ dependencies { include "net.lenni0451.classtransform:additionalclassprovider:1.8.3" include "net.lenni0451:Reflect:1.0.2" include "net.lenni0451:LambdaEvents:2.0.3" - include "net.raphimc.netminecraft:all:2.2.3" + include "net.raphimc.netminecraft:all:2.3.0" include("net.raphimc:MinecraftAuth:2.0.1") { exclude group: "com.google.code.gson", module: "gson" exclude group: "org.slf4j", module: "slf4j-api" diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/Client2ProxyChannelInitializeEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/Client2ProxyChannelInitializeEvent.java index 8dbdc28..f9af97b 100644 --- a/src/main/java/net/raphimc/viaproxy/plugins/events/Client2ProxyChannelInitializeEvent.java +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/Client2ProxyChannelInitializeEvent.java @@ -17,23 +17,23 @@ */ package net.raphimc.viaproxy.plugins.events; -import io.netty.channel.socket.SocketChannel; +import io.netty.channel.Channel; import net.raphimc.viaproxy.plugins.events.types.ICancellable; import net.raphimc.viaproxy.plugins.events.types.ITyped; public class Client2ProxyChannelInitializeEvent implements ICancellable, ITyped { private final Type type; - private final SocketChannel channel; + private final Channel channel; private boolean cancelled; - public Client2ProxyChannelInitializeEvent(final Type type, final SocketChannel channel) { + public Client2ProxyChannelInitializeEvent(final Type type, final Channel channel) { this.type = type; this.channel = channel; } - public SocketChannel getChannel() { + public Channel getChannel() { return this.channel; } diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/Proxy2ServerChannelInitializeEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/Proxy2ServerChannelInitializeEvent.java index c9f5752..3531629 100644 --- a/src/main/java/net/raphimc/viaproxy/plugins/events/Proxy2ServerChannelInitializeEvent.java +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/Proxy2ServerChannelInitializeEvent.java @@ -17,23 +17,23 @@ */ package net.raphimc.viaproxy.plugins.events; -import io.netty.channel.socket.SocketChannel; +import io.netty.channel.Channel; import net.raphimc.viaproxy.plugins.events.types.ICancellable; import net.raphimc.viaproxy.plugins.events.types.ITyped; public class Proxy2ServerChannelInitializeEvent implements ICancellable, ITyped { private final Type type; - private final SocketChannel channel; + private final Channel channel; private boolean cancelled; - public Proxy2ServerChannelInitializeEvent(final Type type, final SocketChannel channel) { + public Proxy2ServerChannelInitializeEvent(final Type type, final Channel channel) { this.type = type; this.channel = channel; } - public SocketChannel getChannel() { + public Channel getChannel() { return this.channel; } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java b/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java index c2c7286..aa6b891 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/ProxyConnection.java @@ -75,7 +75,7 @@ public class ProxyConnection extends NetClient { private Key storedSecretKey; private String classicMpPass; - public ProxyConnection(final Supplier handlerSupplier, final Function, ChannelInitializer> channelInitializerSupplier, final SocketChannel c2p) { + public ProxyConnection(final Supplier handlerSupplier, final Function, ChannelInitializer> channelInitializerSupplier, final SocketChannel c2p) { super(handlerSupplier, channelInitializerSupplier); this.c2p = c2p; } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java index df1bc29..c6cf81a 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/client2proxy/Client2ProxyChannelInitializer.java @@ -17,8 +17,8 @@ */ package net.raphimc.viaproxy.proxy.client2proxy; +import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; -import io.netty.channel.socket.SocketChannel; import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.netty.connection.MinecraftChannelInitializer; import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil; @@ -35,17 +35,17 @@ public class Client2ProxyChannelInitializer extends MinecraftChannelInitializer } @Override - protected void initChannel(SocketChannel socketChannel) { - if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, socketChannel)).isCancelled()) { - socketChannel.close(); + protected void initChannel(Channel channel) { + if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, channel)).isCancelled()) { + channel.close(); return; } - super.initChannel(socketChannel); - socketChannel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(false)); + super.initChannel(channel); + channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(false)); - if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, socketChannel)).isCancelled()) { - socketChannel.close(); + if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel)).isCancelled()) { + channel.close(); } } diff --git a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java index 3e7ad27..2f1a6b7 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/proxy2server/Proxy2ServerChannelInitializer.java @@ -20,8 +20,8 @@ package net.raphimc.viaproxy.proxy.proxy2server; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; +import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; -import io.netty.channel.socket.SocketChannel; import net.raphimc.netminecraft.constants.MCPipeline; import net.raphimc.netminecraft.netty.connection.MinecraftChannelInitializer; import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil; @@ -46,29 +46,29 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer } @Override - protected void initChannel(SocketChannel socketChannel) { - if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, socketChannel)).isCancelled()) { - socketChannel.close(); + protected void initChannel(Channel channel) { + if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, channel)).isCancelled()) { + channel.close(); return; } - final UserConnection user = new UserConnectionImpl(socketChannel, true); + final UserConnection user = new UserConnectionImpl(channel, true); new ProtocolPipelineImpl(user); - ProxyConnection.fromChannel(socketChannel).setUserConnection(user); + ProxyConnection.fromChannel(channel).setUserConnection(user); - super.initChannel(socketChannel); - socketChannel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(true)); - socketChannel.pipeline().addBefore(MCPipeline.PACKET_CODEC_HANDLER_NAME, ViaPipeline.HANDLER_ENCODER_NAME, new ViaEncodeHandler(user)); - socketChannel.pipeline().addBefore(MCPipeline.PACKET_CODEC_HANDLER_NAME, ViaPipeline.HANDLER_DECODER_NAME, new ViaProxyViaDecodeHandler(user)); + super.initChannel(channel); + channel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(true)); + channel.pipeline().addBefore(MCPipeline.PACKET_CODEC_HANDLER_NAME, ViaPipeline.HANDLER_ENCODER_NAME, new ViaEncodeHandler(user)); + channel.pipeline().addBefore(MCPipeline.PACKET_CODEC_HANDLER_NAME, ViaPipeline.HANDLER_DECODER_NAME, new ViaProxyViaDecodeHandler(user)); - if (ProxyConnection.fromChannel(socketChannel).getServerVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) { + if (ProxyConnection.fromChannel(channel).getServerVersion().isOlderThanOrEqualTo(VersionEnum.r1_6_4)) { user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE); - socketChannel.pipeline().addBefore(MCPipeline.SIZER_HANDLER_NAME, ViaPipeline.HANDLER_PRE_NETTY_ENCODER_NAME, new PreNettyEncoder(user)); - socketChannel.pipeline().addBefore(MCPipeline.SIZER_HANDLER_NAME, ViaPipeline.HANDLER_PRE_NETTY_DECODER_NAME, new PreNettyDecoder(user)); + channel.pipeline().addBefore(MCPipeline.SIZER_HANDLER_NAME, ViaPipeline.HANDLER_PRE_NETTY_ENCODER_NAME, new PreNettyEncoder(user)); + channel.pipeline().addBefore(MCPipeline.SIZER_HANDLER_NAME, ViaPipeline.HANDLER_PRE_NETTY_DECODER_NAME, new PreNettyDecoder(user)); } - if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, socketChannel)).isCancelled()) { - socketChannel.close(); + if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, channel)).isCancelled()) { + channel.close(); } }