2020-02-11 05:35:46 +01:00
|
|
|
From fc7555197054cc6c7781cf4588abefd8c07baf09 Mon Sep 17 00:00:00 2001
|
2019-03-02 21:29:46 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sat, 2 Mar 2019 14:55:01 -0500
|
|
|
|
Subject: [PATCH] Handle Excessive Signs in Chunks creating too large of
|
|
|
|
packets
|
|
|
|
|
|
|
|
Also adds a limit to stop sending Sign data to client after 500
|
|
|
|
signs per chunk to limit client lag.
|
|
|
|
|
|
|
|
Use -DPaper.excessiveSignsLimit=500 to configure that limit, or -1
|
|
|
|
to disable the limit and let your players be abused.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
2020-01-22 03:02:07 +01:00
|
|
|
index b1dededc1..e156804f7 100644
|
2019-03-02 21:29:46 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
2019-07-20 06:01:24 +02:00
|
|
|
@@ -212,6 +212,15 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
2019-03-02 21:29:46 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ java.util.List<Packet> extraPackets = packet.getExtraPackets();
|
|
|
|
+ if (extraPackets != null && !extraPackets.isEmpty()) {
|
|
|
|
+ for (Packet extraPacket : extraPackets) {
|
|
|
|
+ this.dispatchPacket(extraPacket, genericfuturelistener);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
}
|
|
|
|
|
2019-05-05 19:19:34 +02:00
|
|
|
private void sendPacketQueue() { this.o(); } // Paper - OBFHELPER
|
2019-03-02 21:29:46 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java
|
2020-01-22 03:02:07 +01:00
|
|
|
index 2d8e6a2f4..8d0965a05 100644
|
2019-03-02 21:29:46 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/Packet.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Packet.java
|
|
|
|
@@ -11,6 +11,7 @@ public interface Packet<T extends PacketListener> {
|
|
|
|
void a(T t0);
|
|
|
|
|
|
|
|
// Paper start
|
|
|
|
+ default java.util.List<Packet> getExtraPackets() { return null; }
|
|
|
|
default boolean packetTooLarge(NetworkManager manager) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2020-01-22 03:02:07 +01:00
|
|
|
index a0b87f89d..47710067a 100644
|
2019-03-02 21:29:46 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
2019-12-12 17:20:43 +01:00
|
|
|
@@ -23,6 +23,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
2019-05-05 19:19:34 +02:00
|
|
|
|
|
|
|
public PacketPlayOutMapChunk() {}
|
2019-03-02 21:29:46 +01:00
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ private final java.util.List<Packet> extraPackets = new java.util.ArrayList<>();
|
|
|
|
+ private static final int SKIP_EXCESSIVE_SIGNS_LIMIT = Integer.getInteger("Paper.excessiveSignsLimit", 500);
|
2019-05-05 19:19:34 +02:00
|
|
|
+
|
|
|
|
+ @Override
|
2019-03-02 21:29:46 +01:00
|
|
|
+ public java.util.List<Packet> getExtraPackets() {
|
|
|
|
+ return extraPackets;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
public PacketPlayOutMapChunk(Chunk chunk, int i) {
|
2019-05-05 19:19:34 +02:00
|
|
|
ChunkCoordIntPair chunkcoordintpair = chunk.getPos();
|
|
|
|
|
2019-12-12 17:20:43 +01:00
|
|
|
@@ -49,6 +58,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
|
|
this.c = this.a(new PacketDataSerializer(this.j()), chunk, i);
|
|
|
|
this.g = Lists.newArrayList();
|
2019-05-05 19:19:34 +02:00
|
|
|
iterator = chunk.getTileEntities().entrySet().iterator();
|
2019-03-02 21:29:46 +01:00
|
|
|
+ int totalSigns = 0; // Paper
|
|
|
|
|
|
|
|
while (iterator.hasNext()) {
|
2019-05-05 19:19:34 +02:00
|
|
|
entry = (Entry) iterator.next();
|
2019-12-12 17:20:43 +01:00
|
|
|
@@ -57,6 +67,14 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
2019-03-02 21:29:46 +01:00
|
|
|
int j = blockposition.getY() >> 4;
|
|
|
|
|
|
|
|
if (this.f() || (i & 1 << j) != 0) {
|
|
|
|
+ // Paper start - send signs separately
|
|
|
|
+ if (tileentity instanceof TileEntitySign) {
|
|
|
|
+ if (SKIP_EXCESSIVE_SIGNS_LIMIT < 0 || ++totalSigns < SKIP_EXCESSIVE_SIGNS_LIMIT) {
|
2019-05-05 19:19:34 +02:00
|
|
|
+ this.extraPackets.add(tileentity.getUpdatePacket());
|
2019-03-02 21:29:46 +01:00
|
|
|
+ }
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-05-05 19:19:34 +02:00
|
|
|
NBTTagCompound nbttagcompound = tileentity.b();
|
2019-03-02 21:29:46 +01:00
|
|
|
if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
|
|
|
|
|
|
|
|
--
|
2020-02-11 05:35:46 +01:00
|
|
|
2.25.0
|
2019-03-02 21:29:46 +01:00
|
|
|
|