geforkt von Mirrors/Paper
5c7081fecc
* 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: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
118 Zeilen
4.8 KiB
Diff
118 Zeilen
4.8 KiB
Diff
From 34995541233e5e9511c8cd8dc0170713871122bf Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 27 Nov 2018 21:18:06 -0500
|
|
Subject: [PATCH] Handle Large Packets disconnecting client
|
|
|
|
If a players inventory is too big to send in a single packet,
|
|
split the inventory set into multiple packets instead.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
|
index c073b04aa9..1652662aef 100644
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
|
@@ -99,6 +99,15 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
|
}
|
|
|
|
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
|
|
+ // Paper start
|
|
+ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) {
|
|
+ if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) {
|
|
+ return;
|
|
+ } else {
|
|
+ throwable = throwable.getCause();
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
if (throwable instanceof SkipEncodeException) {
|
|
NetworkManager.LOGGER.debug("Skipping packet due to errors", throwable.getCause());
|
|
} else {
|
|
diff --git a/src/main/java/net/minecraft/server/Packet.java b/src/main/java/net/minecraft/server/Packet.java
|
|
index 601d4d0fa2..2d8e6a2f4a 100644
|
|
--- a/src/main/java/net/minecraft/server/Packet.java
|
|
+++ b/src/main/java/net/minecraft/server/Packet.java
|
|
@@ -10,6 +10,12 @@ public interface Packet<T extends PacketListener> {
|
|
|
|
void a(T t0);
|
|
|
|
+ // Paper start
|
|
+ default boolean packetTooLarge(NetworkManager manager) {
|
|
+ return false;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
default boolean a() {
|
|
return false;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java
|
|
index 63c4dbd327..b0cfef52cb 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketEncoder.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketEncoder.java
|
|
@@ -49,7 +49,31 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
|
throw throwable;
|
|
}
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ int packetLength = bytebuf.readableBytes();
|
|
+ if (packetLength > MAX_PACKET_SIZE) {
|
|
+ throw new PacketTooLargeException(packet, packetLength);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
}
|
|
}
|
|
+
|
|
+ // Paper start
|
|
+ private static int MAX_PACKET_SIZE = 2097152;
|
|
+
|
|
+ public static class PacketTooLargeException extends RuntimeException {
|
|
+ private final Packet<?> packet;
|
|
+
|
|
+ PacketTooLargeException(Packet<?> packet, int packetLength) {
|
|
+ super("PacketTooLarge - " + packet.getClass().getSimpleName() + " is " + packetLength + ". Max is " + MAX_PACKET_SIZE);
|
|
+ this.packet = packet;
|
|
+ }
|
|
+
|
|
+ public Packet<?> getPacket() {
|
|
+ return packet;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
index d19a30ad87..58eccd9c63 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
|
@@ -68,7 +68,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
|
this.d = packetdataserializer.l();
|
|
int i = packetdataserializer.i();
|
|
|
|
- if (i > 2097152) {
|
|
+ if (i > 2097152) { // Paper - if this changes, update PacketEncoder
|
|
throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
|
|
} else {
|
|
this.e = new byte[i];
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutWindowItems.java b/src/main/java/net/minecraft/server/PacketPlayOutWindowItems.java
|
|
index f7c3655671..631234324d 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutWindowItems.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutWindowItems.java
|
|
@@ -9,6 +9,15 @@ public class PacketPlayOutWindowItems implements Packet<PacketListenerPlayOut> {
|
|
private int a;
|
|
private List<ItemStack> b;
|
|
|
|
+ //Paper start
|
|
+ @Override
|
|
+ public boolean packetTooLarge(NetworkManager manager) {
|
|
+ for (int i = 0 ; i < this.b.size() ; i++) {
|
|
+ manager.sendPacket(new PacketPlayOutSetSlot(this.a, i, this.b.get(i)));
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+ // Paper end
|
|
public PacketPlayOutWindowItems() {}
|
|
|
|
public PacketPlayOutWindowItems(int i, NonNullList<ItemStack> nonnulllist) {
|
|
--
|
|
2.21.0
|
|
|