mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-11-06 10:45:37 +01:00
79 lines
3.3 KiB
Diff
79 lines
3.3 KiB
Diff
From 7182131a4230bc24a36f1f0fd7c155edb95e9361 Mon Sep 17 00:00:00 2001
|
|
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
|
|
Date: Wed, 16 Dec 2020 18:30:07 +0800
|
|
Subject: [PATCH] Use pipeline to reduce redundancy
|
|
|
|
|
|
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
|
|
index 5c05f2b94..606866a52 100644
|
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
|
|
@@ -5,6 +5,8 @@ import io.netty.channel.Channel;
|
|
import io.netty.channel.ChannelFutureListener;
|
|
import io.netty.channel.ChannelHandler;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
+import io.netty.channel.ChannelPipeline;
|
|
+
|
|
import java.net.SocketAddress;
|
|
import java.util.concurrent.TimeUnit;
|
|
import lombok.Getter;
|
|
@@ -37,14 +39,18 @@ public class ChannelWrapper
|
|
|
|
public void setProtocol(Protocol protocol)
|
|
{
|
|
- ch.pipeline().get( MinecraftDecoder.class ).setProtocol( protocol );
|
|
- ch.pipeline().get( MinecraftEncoder.class ).setProtocol( protocol );
|
|
+ // FlameCord - Use pipeline to reduce redundancy
|
|
+ final ChannelPipeline pipeline = ch.pipeline();
|
|
+ pipeline.get( MinecraftDecoder.class ).setProtocol( protocol );
|
|
+ pipeline.get( MinecraftEncoder.class ).setProtocol( protocol );
|
|
}
|
|
|
|
public void setVersion(int protocol)
|
|
{
|
|
- ch.pipeline().get( MinecraftDecoder.class ).setProtocolVersion( protocol );
|
|
- ch.pipeline().get( MinecraftEncoder.class ).setProtocolVersion( protocol );
|
|
+ // FlameCord - Use pipeline to reduce redundancy
|
|
+ final ChannelPipeline pipeline = ch.pipeline();
|
|
+ pipeline.get( MinecraftDecoder.class ).setProtocolVersion( protocol );
|
|
+ pipeline.get( MinecraftEncoder.class ).setProtocolVersion( protocol );
|
|
}
|
|
|
|
public void write(Object packet)
|
|
@@ -111,25 +117,27 @@ public class ChannelWrapper
|
|
|
|
public void setCompressionThreshold(int compressionThreshold)
|
|
{
|
|
- if ( ch.pipeline().get( PacketCompressor.class ) == null && compressionThreshold != -1 )
|
|
+ // FlameCord - Use pipeline to reduce redundancy
|
|
+ final ChannelPipeline pipeline = ch.pipeline();
|
|
+ if ( pipeline.get( PacketCompressor.class ) == null && compressionThreshold != -1 )
|
|
{
|
|
addBefore( PipelineUtils.PACKET_ENCODER, "compress", new PacketCompressor() );
|
|
}
|
|
if ( compressionThreshold != -1 )
|
|
{
|
|
- ch.pipeline().get( PacketCompressor.class ).setThreshold( compressionThreshold );
|
|
+ pipeline.get( PacketCompressor.class ).setThreshold( compressionThreshold );
|
|
} else
|
|
{
|
|
- ch.pipeline().remove( "compress" );
|
|
+ pipeline.remove( "compress" );
|
|
}
|
|
|
|
- if ( ch.pipeline().get( PacketDecompressor.class ) == null && compressionThreshold != -1 )
|
|
+ if ( pipeline.get( PacketDecompressor.class ) == null && compressionThreshold != -1 )
|
|
{
|
|
addBefore( PipelineUtils.PACKET_DECODER, "decompress", new PacketDecompressor(compressionThreshold) );
|
|
}
|
|
if ( compressionThreshold == -1 )
|
|
{
|
|
- ch.pipeline().remove( "decompress" );
|
|
+ pipeline.remove( "decompress" );
|
|
}
|
|
}
|
|
}
|
|
--
|
|
2.32.0.windows.1
|
|
|