3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-17 03:50:08 +01:00
Paper/Spigot-Server-Patches/0417-Handle-Excessive-Signs-in-Chunks-creating-too-large-.patch
Shane Freeder fb25dc17c6 Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
da08d022 SPIGOT-4700: Add PlayerFishEvent.State.REEL_IN
0cef14e4 Remove draft API from selectEntities

CraftBukkit Changes:
a46fdbc6 Remove outdated build delay.
3697519b SPIGOT-4708: Fix ExactChoice recipes neglecting material
9ead7009 SPIGOT-4677: Add minecraft.admin.command_feedback permission
c3749a23 Remove the Damage tag from items when it is 0.
f74c7b95 SPIGOT-4706: Can't interact with active item
494eef45 Mention requirement of JIRA ticket for bug fixes
51d62dec SPIGOT-4702: Exception when middle clicking certain slots
be557e69 SPIGOT-4700: Add PlayerFishEvent.State.REEL_IN
2019-04-22 22:36:14 +01:00

90 Zeilen
4.2 KiB
Diff

From d2464a0cfa4f2c0bb30336e4e6d7d757649c7a21 Mon Sep 17 00:00:00 2001
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
index 553637239c..30f646e421 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -221,6 +221,15 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
});
}
+ // Paper start
+ java.util.List<Packet> extraPackets = packet.getExtraPackets();
+ if (extraPackets != null && !extraPackets.isEmpty()) {
+ for (Packet extraPacket : extraPackets) {
+ this.dispatchPacket(extraPacket, genericfuturelistener);
+ }
+ }
+ // Paper end
+
}
// Paper start - Async-Anti-Xray - Stop dispatching further packets and return false if the peeked packet is a chunk packet which is not ready
diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java
index 2d8e6a2f4a..8d0965a053 100644
--- 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
index 4a57e8a3ec..eb54bdb642 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
@@ -23,6 +23,13 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
this.ready = true; // Paper - Async-Anti-Xray - Set the ready flag to true
}
+ // 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);
+ public java.util.List<Packet> getExtraPackets() {
+ return extraPackets;
+ }
+ // Paper end
public PacketPlayOutMapChunk(Chunk chunk, int i) {
ChunkPacketInfo<IBlockData> chunkPacketInfo = chunk.world.chunkPacketBlockController.getChunkPacketInfo(this, chunk, i); // Paper - Anti-Xray - Add chunk packet info
this.a = chunk.locX;
@@ -41,6 +48,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
this.c = this.writeChunk(new PacketDataSerializer(this.h()), chunk, flag, i, chunkPacketInfo); // Paper - Anti-Xray - Add chunk packet info
this.e = Lists.newArrayList();
Iterator iterator = chunk.getTileEntities().entrySet().iterator();
+ int totalSigns = 0; // Paper
while (iterator.hasNext()) {
Entry<BlockPosition, TileEntity> entry = (Entry) iterator.next();
@@ -49,6 +57,15 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
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) {
+ extraPackets.add(tileentity.getUpdatePacket());
+ }
+ continue;
+ }
+ // Paper end
+
NBTTagCompound nbttagcompound = tileentity.aa_();
if (tileentity instanceof TileEntitySkull) { TileEntitySkull.sanitizeTileEntityUUID(nbttagcompound); } // Paper
--
2.21.0