Updated NetMinecraft

This commit is contained in:
RaphiMC 2023-01-28 19:18:06 +01:00
parent 9ac6caa716
commit 3d15cfca8b
6 changed files with 33 additions and 33 deletions

View File

@ -86,7 +86,7 @@ dependencies {
include "net.lenni0451.classtransform:additionalclassprovider:1.8.3" include "net.lenni0451.classtransform:additionalclassprovider:1.8.3"
include "net.lenni0451:Reflect:1.0.2" include "net.lenni0451:Reflect:1.0.2"
include "net.lenni0451:LambdaEvents:2.0.3" 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") { include("net.raphimc:MinecraftAuth:2.0.1") {
exclude group: "com.google.code.gson", module: "gson" exclude group: "com.google.code.gson", module: "gson"
exclude group: "org.slf4j", module: "slf4j-api" exclude group: "org.slf4j", module: "slf4j-api"

View File

@ -17,23 +17,23 @@
*/ */
package net.raphimc.viaproxy.plugins.events; 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.ICancellable;
import net.raphimc.viaproxy.plugins.events.types.ITyped; import net.raphimc.viaproxy.plugins.events.types.ITyped;
public class Client2ProxyChannelInitializeEvent implements ICancellable, ITyped { public class Client2ProxyChannelInitializeEvent implements ICancellable, ITyped {
private final Type type; private final Type type;
private final SocketChannel channel; private final Channel channel;
private boolean cancelled; private boolean cancelled;
public Client2ProxyChannelInitializeEvent(final Type type, final SocketChannel channel) { public Client2ProxyChannelInitializeEvent(final Type type, final Channel channel) {
this.type = type; this.type = type;
this.channel = channel; this.channel = channel;
} }
public SocketChannel getChannel() { public Channel getChannel() {
return this.channel; return this.channel;
} }

View File

@ -17,23 +17,23 @@
*/ */
package net.raphimc.viaproxy.plugins.events; 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.ICancellable;
import net.raphimc.viaproxy.plugins.events.types.ITyped; import net.raphimc.viaproxy.plugins.events.types.ITyped;
public class Proxy2ServerChannelInitializeEvent implements ICancellable, ITyped { public class Proxy2ServerChannelInitializeEvent implements ICancellable, ITyped {
private final Type type; private final Type type;
private final SocketChannel channel; private final Channel channel;
private boolean cancelled; private boolean cancelled;
public Proxy2ServerChannelInitializeEvent(final Type type, final SocketChannel channel) { public Proxy2ServerChannelInitializeEvent(final Type type, final Channel channel) {
this.type = type; this.type = type;
this.channel = channel; this.channel = channel;
} }
public SocketChannel getChannel() { public Channel getChannel() {
return this.channel; return this.channel;
} }

View File

@ -75,7 +75,7 @@ public class ProxyConnection extends NetClient {
private Key storedSecretKey; private Key storedSecretKey;
private String classicMpPass; private String classicMpPass;
public ProxyConnection(final Supplier<ChannelHandler> handlerSupplier, final Function<Supplier<ChannelHandler>, ChannelInitializer<SocketChannel>> channelInitializerSupplier, final SocketChannel c2p) { public ProxyConnection(final Supplier<ChannelHandler> handlerSupplier, final Function<Supplier<ChannelHandler>, ChannelInitializer<Channel>> channelInitializerSupplier, final SocketChannel c2p) {
super(handlerSupplier, channelInitializerSupplier); super(handlerSupplier, channelInitializerSupplier);
this.c2p = c2p; this.c2p = c2p;
} }

View File

@ -17,8 +17,8 @@
*/ */
package net.raphimc.viaproxy.proxy.client2proxy; package net.raphimc.viaproxy.proxy.client2proxy;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.socket.SocketChannel;
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;
@ -35,17 +35,17 @@ public class Client2ProxyChannelInitializer extends MinecraftChannelInitializer
} }
@Override @Override
protected void initChannel(SocketChannel socketChannel) { protected void initChannel(Channel channel) {
if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, socketChannel)).isCancelled()) { if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.PRE, channel)).isCancelled()) {
socketChannel.close(); channel.close();
return; return;
} }
super.initChannel(socketChannel); super.initChannel(channel);
socketChannel.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, socketChannel)).isCancelled()) { if (PluginManager.EVENT_MANAGER.call(new Client2ProxyChannelInitializeEvent(ITyped.Type.POST, channel)).isCancelled()) {
socketChannel.close(); channel.close();
} }
} }

View File

@ -20,8 +20,8 @@ package net.raphimc.viaproxy.proxy.proxy2server;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.connection.UserConnectionImpl; import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.socket.SocketChannel;
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;
@ -46,29 +46,29 @@ public class Proxy2ServerChannelInitializer extends MinecraftChannelInitializer
} }
@Override @Override
protected void initChannel(SocketChannel socketChannel) { protected void initChannel(Channel channel) {
if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, socketChannel)).isCancelled()) { if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.PRE, channel)).isCancelled()) {
socketChannel.close(); channel.close();
return; return;
} }
final UserConnection user = new UserConnectionImpl(socketChannel, true); final UserConnection user = new UserConnectionImpl(channel, true);
new ProtocolPipelineImpl(user); new ProtocolPipelineImpl(user);
ProxyConnection.fromChannel(socketChannel).setUserConnection(user); ProxyConnection.fromChannel(channel).setUserConnection(user);
super.initChannel(socketChannel); super.initChannel(channel);
socketChannel.attr(MCPipeline.PACKET_REGISTRY_ATTRIBUTE_KEY).set(PacketRegistryUtil.getHandshakeRegistry(true)); channel.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)); channel.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)); 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); user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
socketChannel.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_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_DECODER_NAME, new PreNettyDecoder(user));
} }
if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, socketChannel)).isCancelled()) { if (PluginManager.EVENT_MANAGER.call(new Proxy2ServerChannelInitializeEvent(ITyped.Type.POST, channel)).isCancelled()) {
socketChannel.close(); channel.close();
} }
} }