PaperMC/paper-server/patches/sources/net/minecraft/network/Connection.java.patch
CraftBukkit/Spigot 93fea68749 Clear Packet Queue on Disconnect
By: md_5 <git@md-5.net>
2015-07-22 19:04:37 +10:00

83 lines
3 KiB
Diff

--- a/net/minecraft/network/Connection.java
+++ b/net/minecraft/network/Connection.java
@@ -96,6 +96,11 @@
private final Queue<Consumer<Connection>> pendingActions = Queues.newConcurrentLinkedQueue();
public Channel channel;
public SocketAddress address;
+ // Spigot Start
+ public java.util.UUID spoofedUUID;
+ public com.mojang.authlib.properties.Property[] spoofedProfile;
+ public boolean preparing = true;
+ // Spigot End
@Nullable
private volatile PacketListener disconnectListener;
@Nullable
@@ -114,6 +119,7 @@
private volatile DisconnectionDetails delayedDisconnect;
@Nullable
BandwidthDebugMonitor bandwidthDebugMonitor;
+ public String hostname = ""; // CraftBukkit - add field
public Connection(PacketFlow side) {
this.receiving = side;
@@ -123,6 +129,9 @@
super.channelActive(channelhandlercontext);
this.channel = channelhandlercontext.channel();
this.address = this.channel.remoteAddress();
+ // Spigot Start
+ this.preparing = false;
+ // Spigot End
if (this.delayedDisconnect != null) {
this.disconnect(this.delayedDisconnect);
}
@@ -176,6 +185,7 @@
}
}
+ if (net.minecraft.server.MinecraftServer.getServer().isDebugging()) throwable.printStackTrace(); // Spigot
}
protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet<?> packet) {
@@ -205,7 +215,7 @@
}
private static <T extends PacketListener> void genericsFtw(Packet<T> packet, PacketListener listener) {
- packet.handle(listener);
+ packet.handle((T) listener); // CraftBukkit - decompile error
}
private void validateListener(ProtocolInfo<?> state, PacketListener listener) {
@@ -464,12 +474,15 @@
}
public void disconnect(DisconnectionDetails disconnectionInfo) {
+ // Spigot Start
+ this.preparing = false;
+ // Spigot End
if (this.channel == null) {
this.delayedDisconnect = disconnectionInfo;
}
if (this.isConnected()) {
- this.channel.close().awaitUninterruptibly();
+ this.channel.close(); // We can't wait as this may be called from an event loop.
this.disconnectionDetails = disconnectionInfo;
}
@@ -537,7 +550,7 @@
}
public void configurePacketHandler(ChannelPipeline pipeline) {
- pipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter(this) {
+ pipeline.addLast("hackfix", new ChannelOutboundHandlerAdapter() { // CraftBukkit - decompile error
public void write(ChannelHandlerContext channelhandlercontext, Object object, ChannelPromise channelpromise) throws Exception {
super.write(channelhandlercontext, object, channelpromise);
}
@@ -661,6 +674,7 @@
packetlistener1.onDisconnect(disconnectiondetails);
}
+ this.pendingActions.clear(); // Free up packet queue.
}
}