diff --git a/Spigot-Server-Patches/0410-Book-Size-Limits.patch b/Spigot-Server-Patches/0410-Book-Size-Limits.patch index bb7e6e8de4..f153032d22 100644 --- a/Spigot-Server-Patches/0410-Book-Size-Limits.patch +++ b/Spigot-Server-Patches/0410-Book-Size-Limits.patch @@ -1,4 +1,4 @@ -From aa0ed5b528231c1be6efb064fbc79d4a4f5524c4 Mon Sep 17 00:00:00 2001 +From 5eab7e52ae72047453b934937e457646f4c6bfd3 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 16 Nov 2018 23:08:50 -0500 Subject: [PATCH] Book Size Limits @@ -6,7 +6,7 @@ Subject: [PATCH] Book Size Limits Puts some limits on the size of books. diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index bc74ea2f09..ea18ba5880 100644 +index bc74ea2f09..beec4e33c6 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -458,4 +458,11 @@ public class PaperConfig { @@ -14,18 +14,18 @@ index bc74ea2f09..ea18ba5880 100644 } } + -+ public static int maxBookPageSize = 640; -+ public static double maxBookTotalSizeMultiplier = 0.9D; ++ public static int maxBookPageSize = 2560; ++ public static double maxBookTotalSizeMultiplier = 0.98D; + private static void maxBookSize() { + maxBookPageSize = getInt("settings.book-size.page-max", maxBookPageSize); + maxBookTotalSizeMultiplier = getDouble("settings.book-size.total-multiplier", maxBookTotalSizeMultiplier); + } } diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 3427e95e60..c4136640d2 100644 +index 3427e95e60..462ab49762 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java -@@ -750,6 +750,28 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { +@@ -750,6 +750,38 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable { } public void a(PacketPlayInBEdit packetplayinbedit) { @@ -46,8 +46,18 @@ index 3427e95e60..c4136640d2 100644 + minecraftServer.postToMainThread(() -> this.disconnect("Book too large!")); + return; + } -+ byteAllowed += (maxBookPageSize * multiplier); ++ int length = testString.length(); ++ int multibytes = byteLength == length ? byteLength : (int) Math.round((double) byteLength / (double) length); ++ for (int x = 1; x < multibytes; x++) { ++ multiplier *= multiplier; ++ } ++ byteAllowed += (maxBookPageSize * Math.min(1, Math.max(0.1D, (double) length / 255D))) * multiplier; + multiplier *= multiplier; ++ ++ if (multibytes > 1) { ++ // penalize MB some more ++ byteAllowed -= length; ++ } + } + } + // Paper end