Updated Via* API usage

This commit is contained in:
FlorianMichael 2024-02-14 13:48:13 +01:00
parent 65b9a0bd64
commit e5138149b8
No known key found for this signature in database
GPG Key ID: C2FB87E71C425126
3 changed files with 7 additions and 7 deletions

View File

@ -58,11 +58,11 @@ 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());
if (this.version.lowerThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
if (this.version.olderThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
this.user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
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.equals(BedrockProtocolVersion.bedrockLatest)) {
} else if (this.version.equalTo(BedrockProtocolVersion.bedrockLatest)) {
this.user.getProtocolInfo().getPipeline().add(BedrockBaseProtocol.INSTANCE);
ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler());
ctx.pipeline().addBefore(this.lengthSplitterName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler());

View File

@ -55,10 +55,10 @@ public abstract class VLPipeline extends ChannelInboundHandlerAdapter {
public void handlerAdded(ChannelHandlerContext ctx) {
ctx.pipeline().addBefore(this.packetCodecName(), VIA_CODEC_NAME, this.createViaCodec());
if (this.version.lowerThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
if (this.version.olderThanOrEquals(LegacyProtocolVersion.r1_6_4)) {
this.user.getProtocolInfo().getPipeline().add(PreNettyBaseProtocol.INSTANCE);
ctx.pipeline().addBefore(this.lengthCodecName(), VIALEGACY_PRE_NETTY_LENGTH_CODEC_NAME, this.createViaLegacyPreNettyLengthCodec());
} else if (this.version.equals(BedrockProtocolVersion.bedrockLatest)) {
} else if (this.version.equalTo(BedrockProtocolVersion.bedrockLatest)) {
this.user.getProtocolInfo().getPipeline().add(BedrockBaseProtocol.INSTANCE);
ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_DISCONNECT_HANDLER_NAME, this.createViaBedrockDisconnectHandler());
ctx.pipeline().addBefore(this.lengthCodecName(), VIABEDROCK_FRAME_ENCAPSULATION_HANDLER_NAME, this.createViaBedrockFrameEncapsulationHandler());

View File

@ -63,9 +63,9 @@ public class VersionRange {
public boolean contains(final ProtocolVersion version) {
if (this.ranges.stream().anyMatch(range -> range.contains(version))) return true;
if (this.min == null && this.max == null) return true;
else if (this.min == null) return version.lowerThanOrEquals(this.max);
else if (this.max == null) return version.higherThanOrEquals(this.min);
return version.higherThanOrEquals(this.min) && version.lowerThanOrEquals(this.max);
else if (this.min == null) return version.olderThanOrEquals(this.max);
else if (this.max == null) return version.newerThanOrEquals(this.min);
return version.newerThanOrEquals(this.min) && version.olderThanOrEquals(this.max);
}
public ProtocolVersion getMin() {