diff --git a/README.md b/README.md index a21de8d..6797ca0 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ repositories { ``` Here is an example dependency configuration for all components: ```groovy -implementation "com.viaversion:viaversion:5.0.4" +implementation "com.viaversion:viaversion:5.0.5" implementation "com.viaversion:viabackwards-common:5.0.4" implementation "com.viaversion:viarewind-common:4.0.3" implementation "net.raphimc:ViaLegacy:3.0.3" diff --git a/build.gradle b/build.gradle index 180150c..b04e530 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ repositories { } dependencies { - compileOnly "com.viaversion:viaversion-common:5.0.4" + compileOnly "com.viaversion:viaversion-common:5.0.5" compileOnly "com.viaversion:viabackwards-common:5.0.4" compileOnly "com.viaversion:viarewind-common:4.0.3" compileOnly "net.raphimc:ViaLegacy:3.0.3" diff --git a/src/main/java/net/raphimc/vialoader/netty/VLLegacyPipeline.java b/src/main/java/net/raphimc/vialoader/netty/VLLegacyPipeline.java index 120ce4c..b5a3322 100644 --- a/src/main/java/net/raphimc/vialoader/netty/VLLegacyPipeline.java +++ b/src/main/java/net/raphimc/vialoader/netty/VLLegacyPipeline.java @@ -51,7 +51,6 @@ public abstract class VLLegacyPipeline extends ChannelInboundHandlerAdapter { this(user, Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(user)); } - @Deprecated public VLLegacyPipeline(final UserConnection user, final ProtocolVersion version) { this.user = user; this.version = version; @@ -62,16 +61,18 @@ public abstract class VLLegacyPipeline extends ChannelInboundHandlerAdapter { ctx.pipeline().addBefore(this.packetDecoderName(), VIA_DECODER_NAME, this.createViaDecoder()); ctx.pipeline().addBefore(this.packetEncoderName(), VIA_ENCODER_NAME, this.createViaEncoder()); - final ProtocolVersion r1_6_4 = ProtocolVersion.getProtocol(VersionType.RELEASE_INITIAL, 78); - if (r1_6_4.isKnown() && this.version.olderThanOrEqualTo(r1_6_4)) { - ctx.pipeline().addBefore(this.lengthSplitterName(), VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, this.createViaLegacyPreNettyLengthPrepender()); - ctx.pipeline().addBefore(this.lengthPrependerName(), VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, this.createViaLegacyPreNettyLengthRemover()); - } else if (this.version.getName().startsWith("Bedrock")) { - ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler()); - ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler()); - this.replaceLengthSplitter(ctx, this.createViaBedrockBatchLengthCodec()); - ctx.pipeline().remove(this.lengthPrependerName()); - ctx.pipeline().addBefore(VIA_DECODER_NAME, VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockPacketEncapsulationHandler()); + if (this.user.isClientSide()) { + final ProtocolVersion r1_6_4 = ProtocolVersion.getProtocol(VersionType.RELEASE_INITIAL, 78); + if (r1_6_4.isKnown() && this.version.olderThanOrEqualTo(r1_6_4)) { + ctx.pipeline().addBefore(this.lengthSplitterName(), VIALEGACY_PRE_NETTY_LENGTH_PREPENDER_NAME, this.createViaLegacyPreNettyLengthPrepender()); + ctx.pipeline().addBefore(this.lengthPrependerName(), VIALEGACY_PRE_NETTY_LENGTH_REMOVER_NAME, this.createViaLegacyPreNettyLengthRemover()); + } else if (this.version.getName().startsWith("Bedrock")) { + ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler()); + ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler()); + this.replaceLengthSplitter(ctx, this.createViaBedrockBatchLengthCodec()); + ctx.pipeline().remove(this.lengthPrependerName()); + ctx.pipeline().addBefore(VIA_DECODER_NAME, VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockPacketEncapsulationHandler()); + } } } diff --git a/src/main/java/net/raphimc/vialoader/netty/VLPipeline.java b/src/main/java/net/raphimc/vialoader/netty/VLPipeline.java index 1f358d1..54d7102 100644 --- a/src/main/java/net/raphimc/vialoader/netty/VLPipeline.java +++ b/src/main/java/net/raphimc/vialoader/netty/VLPipeline.java @@ -49,7 +49,6 @@ public abstract class VLPipeline extends ChannelInboundHandlerAdapter { this(user, Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(user)); } - @Deprecated public VLPipeline(final UserConnection user, final ProtocolVersion version) { this.user = user; this.version = version; @@ -59,14 +58,16 @@ public abstract class VLPipeline extends ChannelInboundHandlerAdapter { public void handlerAdded(ChannelHandlerContext ctx) { ctx.pipeline().addBefore(this.packetCodecName(), VIA_CODEC_NAME, this.createViaCodec()); - final ProtocolVersion r1_6_4 = ProtocolVersion.getProtocol(VersionType.RELEASE_INITIAL, 78); - if (r1_6_4.isKnown() && this.version.olderThanOrEqualTo(r1_6_4)) { - ctx.pipeline().addBefore(this.lengthCodecName(), VIALEGACY_PRE_NETTY_LENGTH_CODEC_NAME, this.createViaLegacyPreNettyLengthCodec()); - } else if (this.version.getName().startsWith("Bedrock")) { - ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler()); - ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler()); - this.replaceLengthCodec(ctx, this.createViaBedrockBatchLengthCodec()); - ctx.pipeline().addBefore(VIA_CODEC_NAME, VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockPacketEncapsulationHandler()); + if (this.user.isClientSide()) { + final ProtocolVersion r1_6_4 = ProtocolVersion.getProtocol(VersionType.RELEASE_INITIAL, 78); + if (r1_6_4.isKnown() && this.version.olderThanOrEqualTo(r1_6_4)) { + ctx.pipeline().addBefore(this.lengthCodecName(), VIALEGACY_PRE_NETTY_LENGTH_CODEC_NAME, this.createViaLegacyPreNettyLengthCodec()); + } else if (this.version.getName().startsWith("Bedrock")) { + ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler()); + ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler()); + this.replaceLengthCodec(ctx, this.createViaBedrockBatchLengthCodec()); + ctx.pipeline().addBefore(VIA_CODEC_NAME, VIABEDROCK_PACKET_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockPacketEncapsulationHandler()); + } } }