mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 05:40:00 +03:00
572 lines
23 KiB
Diff
572 lines
23 KiB
Diff
--- ../src-base/minecraft/net/minecraft/network/NetworkManager.java
|
|
+++ ../src-work/minecraft/net/minecraft/network/NetworkManager.java
|
|
@@ -26,12 +26,14 @@
|
|
import io.netty.util.AttributeKey;
|
|
import io.netty.util.concurrent.Future;
|
|
import io.netty.util.concurrent.GenericFutureListener;
|
|
+
|
|
import java.net.InetAddress;
|
|
import java.net.SocketAddress;
|
|
import java.util.Queue;
|
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
import javax.annotation.Nullable;
|
|
import javax.crypto.SecretKey;
|
|
+
|
|
import net.minecraft.util.CryptManager;
|
|
import net.minecraft.util.ITickable;
|
|
import net.minecraft.util.LazyLoadBase;
|
|
@@ -46,201 +48,162 @@
|
|
import org.apache.logging.log4j.Marker;
|
|
import org.apache.logging.log4j.MarkerManager;
|
|
|
|
-public class NetworkManager extends SimpleChannelInboundHandler < Packet<? >>
|
|
-{
|
|
+public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
public static final Marker NETWORK_MARKER = MarkerManager.getMarker("NETWORK");
|
|
public static final Marker NETWORK_PACKETS_MARKER = MarkerManager.getMarker("NETWORK_PACKETS", NETWORK_MARKER);
|
|
public static final AttributeKey<EnumConnectionState> PROTOCOL_ATTRIBUTE_KEY = AttributeKey.<EnumConnectionState>valueOf("protocol");
|
|
- public static final LazyLoadBase<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoadBase<NioEventLoopGroup>()
|
|
- {
|
|
- protected NioEventLoopGroup load()
|
|
- {
|
|
+ public static final LazyLoadBase<NioEventLoopGroup> CLIENT_NIO_EVENTLOOP = new LazyLoadBase<NioEventLoopGroup>() {
|
|
+ protected NioEventLoopGroup load() {
|
|
return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Client IO #%d").setDaemon(true).build());
|
|
}
|
|
};
|
|
- public static final LazyLoadBase<EpollEventLoopGroup> CLIENT_EPOLL_EVENTLOOP = new LazyLoadBase<EpollEventLoopGroup>()
|
|
- {
|
|
- protected EpollEventLoopGroup load()
|
|
- {
|
|
+ public static final LazyLoadBase<EpollEventLoopGroup> CLIENT_EPOLL_EVENTLOOP = new LazyLoadBase<EpollEventLoopGroup>() {
|
|
+ protected EpollEventLoopGroup load() {
|
|
return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Client IO #%d").setDaemon(true).build());
|
|
}
|
|
};
|
|
- public static final LazyLoadBase<LocalEventLoopGroup> CLIENT_LOCAL_EVENTLOOP = new LazyLoadBase<LocalEventLoopGroup>()
|
|
- {
|
|
- protected LocalEventLoopGroup load()
|
|
- {
|
|
+ public static final LazyLoadBase<LocalEventLoopGroup> CLIENT_LOCAL_EVENTLOOP = new LazyLoadBase<LocalEventLoopGroup>() {
|
|
+ protected LocalEventLoopGroup load() {
|
|
return new LocalEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Local Client IO #%d").setDaemon(true).build());
|
|
}
|
|
};
|
|
private final EnumPacketDirection direction;
|
|
- private final Queue<NetworkManager.InboundHandlerTuplePacketListener> outboundPacketsQueue = Queues.<NetworkManager.InboundHandlerTuplePacketListener>newConcurrentLinkedQueue();
|
|
+ private final Queue<InboundHandlerTuplePacketListener> outboundPacketsQueue = Queues.<InboundHandlerTuplePacketListener>newConcurrentLinkedQueue();
|
|
private final ReentrantReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
|
- private Channel channel;
|
|
- private SocketAddress socketAddress;
|
|
+ public Channel channel; // CatServer - private -> public
|
|
+ // Spigot Start // PAIL
|
|
+ public SocketAddress socketAddress;
|
|
+ public java.util.UUID spoofedUUID;
|
|
+ public com.mojang.authlib.properties.Property[] spoofedProfile;
|
|
+ // Spigot End
|
|
+ public boolean preparing = true; // Spigot
|
|
private INetHandler packetListener;
|
|
private ITextComponent terminationReason;
|
|
private boolean isEncrypted;
|
|
private boolean disconnected;
|
|
|
|
- public NetworkManager(EnumPacketDirection packetDirection)
|
|
- {
|
|
+ public NetworkManager(EnumPacketDirection packetDirection) {
|
|
this.direction = packetDirection;
|
|
}
|
|
|
|
- public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception
|
|
- {
|
|
+ public EnumPacketDirection getDirection() {
|
|
+ return this.direction;
|
|
+ }
|
|
+
|
|
+ public void channelActive(ChannelHandlerContext p_channelActive_1_) throws Exception {
|
|
super.channelActive(p_channelActive_1_);
|
|
this.channel = p_channelActive_1_.channel();
|
|
this.socketAddress = this.channel.remoteAddress();
|
|
+ this.preparing = false; // Spigot
|
|
|
|
- try
|
|
- {
|
|
+ try {
|
|
this.setConnectionState(EnumConnectionState.HANDSHAKING);
|
|
- }
|
|
- catch (Throwable throwable)
|
|
- {
|
|
+ } catch (Throwable throwable) {
|
|
LOGGER.fatal(throwable);
|
|
}
|
|
}
|
|
|
|
- public void setConnectionState(EnumConnectionState newState)
|
|
- {
|
|
+ public void setConnectionState(EnumConnectionState newState) {
|
|
this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).set(newState);
|
|
this.channel.config().setAutoRead(true);
|
|
LOGGER.debug("Enabled auto read");
|
|
}
|
|
|
|
- public void channelInactive(ChannelHandlerContext p_channelInactive_1_) throws Exception
|
|
- {
|
|
+ public void channelInactive(ChannelHandlerContext p_channelInactive_1_) throws Exception {
|
|
this.closeChannel(new TextComponentTranslation("disconnect.endOfStream", new Object[0]));
|
|
}
|
|
|
|
- public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwable p_exceptionCaught_2_) throws Exception
|
|
- {
|
|
+ public void exceptionCaught(ChannelHandlerContext p_exceptionCaught_1_, Throwable p_exceptionCaught_2_) throws Exception {
|
|
TextComponentTranslation textcomponenttranslation;
|
|
|
|
- if (p_exceptionCaught_2_ instanceof TimeoutException)
|
|
- {
|
|
+ if (p_exceptionCaught_2_ instanceof TimeoutException) {
|
|
textcomponenttranslation = new TextComponentTranslation("disconnect.timeout", new Object[0]);
|
|
+ } else {
|
|
+ textcomponenttranslation = new TextComponentTranslation("disconnect.genericReason", new Object[]{"Internal Exception: " + p_exceptionCaught_2_});
|
|
}
|
|
- else
|
|
- {
|
|
- textcomponenttranslation = new TextComponentTranslation("disconnect.genericReason", new Object[] {"Internal Exception: " + p_exceptionCaught_2_});
|
|
- }
|
|
|
|
LOGGER.debug(textcomponenttranslation.getUnformattedText(), p_exceptionCaught_2_);
|
|
this.closeChannel(textcomponenttranslation);
|
|
}
|
|
|
|
- protected void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_) throws Exception
|
|
- {
|
|
- if (this.channel.isOpen())
|
|
- {
|
|
- try
|
|
- {
|
|
- ((Packet<INetHandler>)p_channelRead0_2_).processPacket(this.packetListener);
|
|
- }
|
|
- catch (ThreadQuickExitException var4)
|
|
- {
|
|
+ protected void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_) throws Exception {
|
|
+ if (this.channel.isOpen()) {
|
|
+ try {
|
|
+ ((Packet<INetHandler>) p_channelRead0_2_).processPacket(this.packetListener);
|
|
+ } catch (ThreadQuickExitException var4) {
|
|
;
|
|
}
|
|
}
|
|
}
|
|
|
|
- public void setNetHandler(INetHandler handler)
|
|
- {
|
|
+ public void setNetHandler(INetHandler handler) {
|
|
Validate.notNull(handler, "packetListener");
|
|
LOGGER.debug("Set listener of {} to {}", this, handler);
|
|
this.packetListener = handler;
|
|
}
|
|
|
|
- public void sendPacket(Packet<?> packetIn)
|
|
- {
|
|
- if (this.isChannelOpen())
|
|
- {
|
|
+ public void sendPacket(Packet<?> packetIn) {
|
|
+ if (this.isChannelOpen()) {
|
|
this.flushOutboundQueue();
|
|
- this.dispatchPacket(packetIn, (GenericFutureListener[])null);
|
|
- }
|
|
- else
|
|
- {
|
|
+ this.dispatchPacket(packetIn, (GenericFutureListener[]) null);
|
|
+ } else {
|
|
this.readWriteLock.writeLock().lock();
|
|
|
|
- try
|
|
- {
|
|
- this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, new GenericFutureListener[0]));
|
|
- }
|
|
- finally
|
|
- {
|
|
+ try {
|
|
+ this.outboundPacketsQueue.add(new InboundHandlerTuplePacketListener(packetIn, new GenericFutureListener[0]));
|
|
+ } finally {
|
|
this.readWriteLock.writeLock().unlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
- public void sendPacket(Packet<?> packetIn, GenericFutureListener <? extends Future <? super Void >> listener, GenericFutureListener <? extends Future <? super Void >> ... listeners)
|
|
- {
|
|
- if (this.isChannelOpen())
|
|
- {
|
|
+ public void sendPacket(Packet<?> packetIn, GenericFutureListener<? extends Future<? super Void>> listener, GenericFutureListener<? extends Future<? super Void>>... listeners) {
|
|
+ if (this.isChannelOpen()) {
|
|
this.flushOutboundQueue();
|
|
- this.dispatchPacket(packetIn, (GenericFutureListener[])ArrayUtils.add(listeners, 0, listener));
|
|
- }
|
|
- else
|
|
- {
|
|
+ this.dispatchPacket(packetIn, (GenericFutureListener[]) ArrayUtils.add(listeners, 0, listener));
|
|
+ } else {
|
|
this.readWriteLock.writeLock().lock();
|
|
|
|
- try
|
|
- {
|
|
- this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[])ArrayUtils.add(listeners, 0, listener)));
|
|
- }
|
|
- finally
|
|
- {
|
|
+ try {
|
|
+ this.outboundPacketsQueue.add(new InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[]) ArrayUtils.add(listeners, 0, listener)));
|
|
+ } finally {
|
|
this.readWriteLock.writeLock().unlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
- private void dispatchPacket(final Packet<?> inPacket, @Nullable final GenericFutureListener <? extends Future <? super Void >> [] futureListeners)
|
|
- {
|
|
+ private void dispatchPacket(final Packet<?> inPacket, @Nullable final GenericFutureListener<? extends Future<? super Void>>[] futureListeners) {
|
|
final EnumConnectionState enumconnectionstate = EnumConnectionState.getFromPacket(inPacket);
|
|
- final EnumConnectionState enumconnectionstate1 = (EnumConnectionState)this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).get();
|
|
+ final EnumConnectionState enumconnectionstate1 = (EnumConnectionState) this.channel.attr(PROTOCOL_ATTRIBUTE_KEY).get();
|
|
|
|
- if (enumconnectionstate1 != enumconnectionstate)
|
|
- {
|
|
+ if (enumconnectionstate1 != enumconnectionstate && !(inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket)) {
|
|
LOGGER.debug("Disabled auto read");
|
|
this.channel.config().setAutoRead(false);
|
|
}
|
|
|
|
- if (this.channel.eventLoop().inEventLoop())
|
|
- {
|
|
- if (enumconnectionstate != enumconnectionstate1)
|
|
- {
|
|
+ if (this.channel.eventLoop().inEventLoop()) {
|
|
+ if (enumconnectionstate != enumconnectionstate1 && !(inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket)) {
|
|
this.setConnectionState(enumconnectionstate);
|
|
}
|
|
|
|
ChannelFuture channelfuture = this.channel.writeAndFlush(inPacket);
|
|
|
|
- if (futureListeners != null)
|
|
- {
|
|
+ if (futureListeners != null) {
|
|
channelfuture.addListeners(futureListeners);
|
|
}
|
|
|
|
channelfuture.addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
|
|
- }
|
|
- else
|
|
- {
|
|
- this.channel.eventLoop().execute(new Runnable()
|
|
- {
|
|
- public void run()
|
|
- {
|
|
- if (enumconnectionstate != enumconnectionstate1)
|
|
- {
|
|
+ } else {
|
|
+ this.channel.eventLoop().execute(new Runnable() {
|
|
+ public void run() {
|
|
+ if (enumconnectionstate != enumconnectionstate1 && !(inPacket instanceof net.minecraftforge.fml.common.network.internal.FMLProxyPacket)) {
|
|
NetworkManager.this.setConnectionState(enumconnectionstate);
|
|
}
|
|
|
|
ChannelFuture channelfuture1 = NetworkManager.this.channel.writeAndFlush(inPacket);
|
|
|
|
- if (futureListeners != null)
|
|
- {
|
|
+ if (futureListeners != null) {
|
|
channelfuture1.addListeners(futureListeners);
|
|
}
|
|
|
|
@@ -250,89 +213,71 @@
|
|
}
|
|
}
|
|
|
|
- private void flushOutboundQueue()
|
|
- {
|
|
- if (this.channel != null && this.channel.isOpen())
|
|
- {
|
|
+ private void flushOutboundQueue() {
|
|
+ if (this.channel != null && this.channel.isOpen()) {
|
|
this.readWriteLock.readLock().lock();
|
|
|
|
- try
|
|
- {
|
|
- while (!this.outboundPacketsQueue.isEmpty())
|
|
- {
|
|
- NetworkManager.InboundHandlerTuplePacketListener networkmanager$inboundhandlertuplepacketlistener = this.outboundPacketsQueue.poll();
|
|
+ try {
|
|
+ while (!this.outboundPacketsQueue.isEmpty()) {
|
|
+ InboundHandlerTuplePacketListener networkmanager$inboundhandlertuplepacketlistener = this.outboundPacketsQueue.poll();
|
|
this.dispatchPacket(networkmanager$inboundhandlertuplepacketlistener.packet, networkmanager$inboundhandlertuplepacketlistener.futureListeners);
|
|
}
|
|
- }
|
|
- finally
|
|
- {
|
|
+ } finally {
|
|
this.readWriteLock.readLock().unlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
- public void processReceivedPackets()
|
|
- {
|
|
+ public void processReceivedPackets() {
|
|
this.flushOutboundQueue();
|
|
|
|
- if (this.packetListener instanceof ITickable)
|
|
- {
|
|
- ((ITickable)this.packetListener).update();
|
|
+ if (this.packetListener instanceof ITickable) {
|
|
+ ((ITickable) this.packetListener).update();
|
|
}
|
|
|
|
- if (this.channel != null)
|
|
- {
|
|
+ if (this.channel != null) {
|
|
this.channel.flush();
|
|
}
|
|
}
|
|
|
|
- public SocketAddress getRemoteAddress()
|
|
- {
|
|
+ public SocketAddress getRemoteAddress() {
|
|
return this.socketAddress;
|
|
}
|
|
|
|
- public void closeChannel(ITextComponent message)
|
|
- {
|
|
- if (this.channel.isOpen())
|
|
- {
|
|
- this.channel.close().awaitUninterruptibly();
|
|
+ public void closeChannel(ITextComponent message) {
|
|
+ this.preparing = false; // Spigot
|
|
+ if (this.channel.isOpen()) {
|
|
+ // We can't wait as this may be called from an event loop.
|
|
+ // this.channel.close().awaitUninterruptibly();
|
|
+ this.channel.close();
|
|
this.terminationReason = message;
|
|
}
|
|
}
|
|
|
|
- public boolean isLocalChannel()
|
|
- {
|
|
+ public boolean isLocalChannel() {
|
|
return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel;
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
- public static NetworkManager createNetworkManagerAndConnect(InetAddress address, int serverPort, boolean useNativeTransport)
|
|
- {
|
|
+ public static NetworkManager createNetworkManagerAndConnect(InetAddress address, int serverPort, boolean useNativeTransport) {
|
|
+ if (address instanceof java.net.Inet6Address) System.setProperty("java.net.preferIPv4Stack", "false");
|
|
final NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
|
|
- Class <? extends SocketChannel > oclass;
|
|
- LazyLoadBase <? extends EventLoopGroup > lazyloadbase;
|
|
+ Class<? extends SocketChannel> oclass;
|
|
+ LazyLoadBase<? extends EventLoopGroup> lazyloadbase;
|
|
|
|
- if (Epoll.isAvailable() && useNativeTransport)
|
|
- {
|
|
+ if (Epoll.isAvailable() && useNativeTransport) {
|
|
oclass = EpollSocketChannel.class;
|
|
lazyloadbase = CLIENT_EPOLL_EVENTLOOP;
|
|
- }
|
|
- else
|
|
- {
|
|
+ } else {
|
|
oclass = NioSocketChannel.class;
|
|
lazyloadbase = CLIENT_NIO_EVENTLOOP;
|
|
}
|
|
|
|
- ((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(lazyloadbase.getValue())).handler(new ChannelInitializer<Channel>()
|
|
- {
|
|
- protected void initChannel(Channel p_initChannel_1_) throws Exception
|
|
- {
|
|
- try
|
|
- {
|
|
+ ((Bootstrap) ((Bootstrap) ((Bootstrap) (new Bootstrap()).group(lazyloadbase.getValue())).handler(new ChannelInitializer<Channel>() {
|
|
+ protected void initChannel(Channel p_initChannel_1_) throws Exception {
|
|
+ try {
|
|
p_initChannel_1_.config().setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(true));
|
|
- }
|
|
- catch (ChannelException var3)
|
|
- {
|
|
+ } catch (ChannelException var3) {
|
|
;
|
|
}
|
|
|
|
@@ -343,126 +288,105 @@
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
- public static NetworkManager provideLocalClient(SocketAddress address)
|
|
- {
|
|
+ public static NetworkManager provideLocalClient(SocketAddress address) {
|
|
final NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
|
|
- ((Bootstrap)((Bootstrap)((Bootstrap)(new Bootstrap()).group(CLIENT_LOCAL_EVENTLOOP.getValue())).handler(new ChannelInitializer<Channel>()
|
|
- {
|
|
- protected void initChannel(Channel p_initChannel_1_) throws Exception
|
|
- {
|
|
+ ((Bootstrap) ((Bootstrap) ((Bootstrap) (new Bootstrap()).group(CLIENT_LOCAL_EVENTLOOP.getValue())).handler(new ChannelInitializer<Channel>() {
|
|
+ protected void initChannel(Channel p_initChannel_1_) throws Exception {
|
|
p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager);
|
|
}
|
|
})).channel(LocalChannel.class)).connect(address).syncUninterruptibly();
|
|
return networkmanager;
|
|
}
|
|
|
|
- public void enableEncryption(SecretKey key)
|
|
- {
|
|
+ public void enableEncryption(SecretKey key) {
|
|
this.isEncrypted = true;
|
|
this.channel.pipeline().addBefore("splitter", "decrypt", new NettyEncryptingDecoder(CryptManager.createNetCipherInstance(2, key)));
|
|
this.channel.pipeline().addBefore("prepender", "encrypt", new NettyEncryptingEncoder(CryptManager.createNetCipherInstance(1, key)));
|
|
}
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
- public boolean isEncrypted()
|
|
- {
|
|
+ public boolean isEncrypted() {
|
|
return this.isEncrypted;
|
|
}
|
|
|
|
- public boolean isChannelOpen()
|
|
- {
|
|
+ public boolean isChannelOpen() {
|
|
return this.channel != null && this.channel.isOpen();
|
|
}
|
|
|
|
- public boolean hasNoChannel()
|
|
- {
|
|
+ public boolean hasNoChannel() {
|
|
return this.channel == null;
|
|
}
|
|
|
|
- public INetHandler getNetHandler()
|
|
- {
|
|
+ public INetHandler getNetHandler() {
|
|
return this.packetListener;
|
|
}
|
|
|
|
- public ITextComponent getExitMessage()
|
|
- {
|
|
+ public ITextComponent getExitMessage() {
|
|
return this.terminationReason;
|
|
}
|
|
|
|
- public void disableAutoRead()
|
|
- {
|
|
+ public void disableAutoRead() {
|
|
this.channel.config().setAutoRead(false);
|
|
}
|
|
|
|
- public void setCompressionThreshold(int threshold)
|
|
- {
|
|
- if (threshold >= 0)
|
|
- {
|
|
- if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
|
- {
|
|
- ((NettyCompressionDecoder)this.channel.pipeline().get("decompress")).setCompressionThreshold(threshold);
|
|
+ public void setCompressionThreshold(int threshold) {
|
|
+ if (threshold >= 0) {
|
|
+ if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder) {
|
|
+ ((NettyCompressionDecoder) this.channel.pipeline().get("decompress")).setCompressionThreshold(threshold);
|
|
+ } else {
|
|
+ this.channel.pipeline().addAfter("splitter", "decompress", new NettyCompressionDecoder(threshold)); // CatServer
|
|
}
|
|
- else
|
|
- {
|
|
- this.channel.pipeline().addBefore("decoder", "decompress", new NettyCompressionDecoder(threshold));
|
|
- }
|
|
|
|
- if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
|
- {
|
|
- ((NettyCompressionEncoder)this.channel.pipeline().get("compress")).setCompressionThreshold(threshold);
|
|
- }
|
|
- else
|
|
- {
|
|
+ if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder) {
|
|
+ ((NettyCompressionEncoder) this.channel.pipeline().get("compress")).setCompressionThreshold(threshold);
|
|
+ } else {
|
|
this.channel.pipeline().addBefore("encoder", "compress", new NettyCompressionEncoder(threshold));
|
|
}
|
|
- }
|
|
- else
|
|
- {
|
|
- if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder)
|
|
- {
|
|
+ } else {
|
|
+ if (this.channel.pipeline().get("decompress") instanceof NettyCompressionDecoder) {
|
|
this.channel.pipeline().remove("decompress");
|
|
}
|
|
|
|
- if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder)
|
|
- {
|
|
+ if (this.channel.pipeline().get("compress") instanceof NettyCompressionEncoder) {
|
|
this.channel.pipeline().remove("compress");
|
|
}
|
|
}
|
|
}
|
|
|
|
- public void checkDisconnected()
|
|
- {
|
|
- if (this.channel != null && !this.channel.isOpen())
|
|
- {
|
|
- if (this.disconnected)
|
|
- {
|
|
+ public void checkDisconnected() {
|
|
+ if (this.channel != null && !this.channel.isOpen()) {
|
|
+ if (this.disconnected) {
|
|
LOGGER.warn("handleDisconnection() called twice");
|
|
- }
|
|
- else
|
|
- {
|
|
+ } else {
|
|
this.disconnected = true;
|
|
|
|
- if (this.getExitMessage() != null)
|
|
- {
|
|
+ if (this.getExitMessage() != null) {
|
|
this.getNetHandler().onDisconnect(this.getExitMessage());
|
|
- }
|
|
- else if (this.getNetHandler() != null)
|
|
- {
|
|
+ } else if (this.getNetHandler() != null) {
|
|
this.getNetHandler().onDisconnect(new TextComponentTranslation("multiplayer.disconnect.generic", new Object[0]));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
- static class InboundHandlerTuplePacketListener
|
|
- {
|
|
- private final Packet<?> packet;
|
|
- private final GenericFutureListener <? extends Future <? super Void >> [] futureListeners;
|
|
+ public Channel channel() {
|
|
+ return channel;
|
|
+ }
|
|
|
|
- public InboundHandlerTuplePacketListener(Packet<?> inPacket, GenericFutureListener <? extends Future <? super Void >> ... inFutureListeners)
|
|
- {
|
|
- this.packet = inPacket;
|
|
- this.futureListeners = inFutureListeners;
|
|
- }
|
|
+ static class InboundHandlerTuplePacketListener {
|
|
+ private final Packet<?> packet;
|
|
+ private final GenericFutureListener<? extends Future<? super Void>>[] futureListeners;
|
|
+
|
|
+ public InboundHandlerTuplePacketListener(Packet<?> inPacket, GenericFutureListener<? extends Future<? super Void>>... inFutureListeners) {
|
|
+ this.packet = inPacket;
|
|
+ this.futureListeners = inFutureListeners;
|
|
}
|
|
+ }
|
|
+ // Spigot Start
|
|
+ public SocketAddress getRawAddress()
|
|
+ {
|
|
+ return this.channel.remoteAddress();
|
|
+ }
|
|
+// Spigot End
|
|
+
|
|
}
|