This commit is contained in:
Jake Potrebic
2022-08-05 15:58:34 -07:00
parent 522db24de0
commit 2782b0c375
20 changed files with 108 additions and 124 deletions

View File

@@ -56,19 +56,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
net.minecraft.server.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() &&
(packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty())
))) {
- this.sendPacket(packet, packetsendlistener);
+ this.sendPacket(packet, packetsendlistener, null); // Paper
- this.sendPacket(packet, callbacks);
+ this.sendPacket(packet, callbacks, null); // Paper
return;
}
// write the packets to the queue, then flush - antixray hooks there already
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener) {
private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks) {
+ // Paper start - add flush parameter
+ this.sendPacket(packet, packetsendlistener, Boolean.TRUE);
+ this.sendPacket(packet, callbacks, Boolean.TRUE);
+ }
+ private void sendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, Boolean flushConditional) {
+ private void sendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, Boolean flushConditional) {
+ this.packetWrites.getAndIncrement(); // must be befeore using canFlush
+ boolean effectiveFlush = flushConditional == null ? this.canFlush : flushConditional.booleanValue();
+ final boolean flush = effectiveFlush || packet instanceof net.minecraft.network.protocol.game.ClientboundKeepAlivePacket || packet instanceof ClientboundDisconnectPacket; // no delay for certain packets
@@ -80,22 +80,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
if (this.channel.eventLoop().inEventLoop()) {
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
- this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
} else {
this.channel.eventLoop().execute(() -> {
- this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, packetsendlistener, enumprotocol, enumprotocol1, flush); // Paper - add flush parameter
- this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1);
+ this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper
});
}
}
private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, ConnectionProtocol packetState, ConnectionProtocol currentState) {
private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, ConnectionProtocol packetState, ConnectionProtocol currentState) {
+ // Paper start - add flush parameter
+ this.doSendPacket(packet, packetsendlistener, packetState, currentState, true);
+ this.doSendPacket(packet, callbacks, packetState, currentState, true);
+ }
+ private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener packetsendlistener, ConnectionProtocol packetState, ConnectionProtocol currentState, boolean flush) {
+ private void doSendPacket(Packet<?> packet, @Nullable PacketSendListener callbacks, ConnectionProtocol packetState, ConnectionProtocol currentState, boolean flush) {
+ // Paper end - add flush parameter
if (packetState != currentState) {
this.setProtocol(packetState);
@@ -107,7 +107,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- ChannelFuture channelfuture = this.channel.writeAndFlush(packet);
+ ChannelFuture channelfuture = flush ? this.channel.writeAndFlush(packet) : this.channel.write(packet); // Paper - add flush parameter
if (packetsendlistener != null) {
if (callbacks != null) {
channelfuture.addListener((future) -> {
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}