use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaVersion by ViaVersion.
the class BungeeChannelInitializer method initChannel.
@Override
protected void initChannel(Channel socketChannel) throws Exception {
if (!socketChannel.isActive()) {
return;
}
UserConnection info = new UserConnectionImpl(socketChannel);
// init protocol
new ProtocolPipelineImpl(info);
// Add originals
this.method.invoke(this.original, socketChannel);
// Don't inject if inactive
if (!socketChannel.isActive())
return;
// Don't inject if no packet-encoder
if (socketChannel.pipeline().get("packet-encoder") == null)
return;
// Don't inject if no packet-decoder
if (socketChannel.pipeline().get("packet-decoder") == null)
return;
// Add our transformers
BungeeEncodeHandler encoder = new BungeeEncodeHandler(info);
BungeeDecodeHandler decoder = new BungeeDecodeHandler(info);
socketChannel.pipeline().addBefore("packet-encoder", "via-encoder", encoder);
socketChannel.pipeline().addBefore("packet-decoder", "via-decoder", decoder);
}
use of com.viaversion.viaversion.connection.UserConnectionImpl in project LiquidBouncePlus by WYSI-Foundation.
the class MixinNetworkManagerChInit method onInitChannel.
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel && ViaForge.getInstance().getVersion() != ViaForge.SHARED_VERSION) {
UserConnection user = new UserConnectionImpl(channel, true);
new ProtocolPipelineImpl(user);
channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new EncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new DecodeHandler(user));
}
}
use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaFabric by ViaVersion.
the class MixinServerNetworkIoChInit method onInitChannel.
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) {
UserConnection user = new UserConnectionImpl(channel);
new ProtocolPipelineImpl(user);
channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
}
}
use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaFabric by ViaVersion.
the class MixinClientConnectionChInit method onInitChannel.
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) {
UserConnection user = new UserConnectionImpl(channel, true);
new ProtocolPipelineImpl(user).add(HostnameParserProtocol.INSTANCE);
channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
}
}
use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaFabric by ViaVersion.
the class MixinServerNetworkIoChInit method onInitChannel.
@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
if (channel instanceof SocketChannel) {
UserConnection user = new UserConnectionImpl(channel);
new ProtocolPipelineImpl(user);
channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
}
}
Aggregations