diff --git a/patches/server/Add-PlayerKickEvent-causes.patch b/patches/server/Add-PlayerKickEvent-causes.patch index 7fd76c1acc..c4d0896a73 100644 --- a/patches/server/Add-PlayerKickEvent-causes.patch +++ b/patches/server/Add-PlayerKickEvent-causes.patch @@ -285,18 +285,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed @@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; - if (byteLength > 256 * 4) { - ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!"); -- this.disconnect(Component.literal("Book too large!")); -+ this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause - return; - } - byteTotal += byteLength; -@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl if (byteTotal > byteAllowed) { - ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); + ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size()); - this.disconnect(Component.literal("Book too large!")); + this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause return; diff --git a/patches/server/Book-Size-Limits.patch b/patches/server/Book-size-limits.patch similarity index 72% rename from patches/server/Book-Size-Limits.patch rename to patches/server/Book-size-limits.patch index 7a49f08e7d..3fde33a6c3 100644 --- a/patches/server/Book-Size-Limits.patch +++ b/patches/server/Book-size-limits.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 16 Nov 2018 23:08:50 -0500 -Subject: [PATCH] Book Size Limits +Subject: [PATCH] Book size limits Puts some limits on the size of books. @@ -18,15 +18,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + List pageList = packet.pages(); + long byteTotal = 0; + int maxBookPageSize = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax; -+ double multiplier = Math.max(0.3D, Math.min(1D, io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier)); ++ double multiplier = Math.clamp(io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier, 0.3D, 1D); + long byteAllowed = maxBookPageSize; + for (String testString : pageList) { + int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; -+ if (byteLength > 256 * 4) { -+ ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with with a page too large!"); -+ this.disconnect(Component.literal("Book too large!")); -+ return; -+ } + byteTotal += byteLength; + int length = testString.length(); + int multibytes = 0; @@ -37,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } + } -+ byteAllowed += (maxBookPageSize * Math.min(1, Math.max(0.1D, (double) length / 255D))) * multiplier; ++ byteAllowed += maxBookPageSize * Math.clamp((double) length / 255D, 0.1D, 1) * multiplier; + + if (multibytes > 1) { + // penalize MB @@ -46,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + if (byteTotal > byteAllowed) { -+ ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send too large of a book. Book Size: " + byteTotal + " - Allowed: "+ byteAllowed + " - Pages: " + pageList.size()); ++ ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size()); + this.disconnect(Component.literal("Book too large!")); + return; + } diff --git a/patches/server/Improve-tag-parser-handling.patch b/patches/server/Improve-tag-parser-handling.patch index 980c3818a2..c53d630f34 100644 --- a/patches/server/Improve-tag-parser-handling.patch +++ b/patches/server/Improve-tag-parser-handling.patch @@ -109,6 +109,19 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + } } +diff --git a/src/main/java/net/minecraft/network/chat/contents/SelectorContents.java b/src/main/java/net/minecraft/network/chat/contents/SelectorContents.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/network/chat/contents/SelectorContents.java ++++ b/src/main/java/net/minecraft/network/chat/contents/SelectorContents.java +@@ -0,0 +0,0 @@ public class SelectorContents implements ComponentContents { + EntitySelectorParser entitySelectorParser = new EntitySelectorParser(new StringReader(pattern), true); + entitySelector = entitySelectorParser.parse(); + } catch (CommandSyntaxException var3) { +- LOGGER.warn("Invalid selector component: {}: {}", pattern, var3.getMessage()); ++ return null; // Paper + } + + return entitySelector; diff --git a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java b/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java