-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e6a2a1
commit f4205c4
Showing
38 changed files
with
108 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Aikar <[email protected]> | ||
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. | ||
|
||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java | ||
index 2e35c6cfdf0cded5adc9f512612faaa68876961c..abab7c6ce2079a0101c59c130fd65db7b2a73498 100644 | ||
index 2e35c6cfdf0cded5adc9f512612faaa68876961c..21f33f2628067644a5f4e1f68127abab0b0849bd 100644 | ||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java | ||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java | ||
@@ -1043,6 +1043,45 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl | ||
@@ -1043,6 +1043,40 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl | ||
|
||
@Override | ||
public void handleEditBook(ServerboundEditBookPacket packet) { | ||
|
@@ -18,15 +18,10 @@ index 2e35c6cfdf0cded5adc9f512612faaa68876961c..abab7c6ce2079a0101c59c130fd65db7 | |
+ List<String> 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 2e35c6cfdf0cded5adc9f512612faaa68876961c..abab7c6ce2079a0101c59c130fd65db7 | |
+ } | ||
+ } | ||
+ } | ||
+ 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 2e35c6cfdf0cded5adc9f512612faaa68876961c..abab7c6ce2079a0101c59c130fd65db7 | |
+ } | ||
+ | ||
+ 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; | ||
+ } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,10 @@ Subject: [PATCH] Fix interact event not being called sometimes | |
Co-authored-by: Moulberry <[email protected]> | ||
|
||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java | ||
index a0bac2fe6222964b098cfaf9470f09c43328fcf5..09e40d6e50b7c1ddd1451981d05ecbbef43cfed2 100644 | ||
index cdf29c17cac7a5bcfcd12d6e306efad0bc87a382..afed142d5155c178807c6b26cb5766ae7d6e328a 100644 | ||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java | ||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java | ||
@@ -1771,7 +1771,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl | ||
@@ -1766,7 +1766,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl | ||
MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED); | ||
|
||
this.player.sendSystemMessage(ichatmutablecomponent, true); | ||
|
@@ -23,7 +23,7 @@ index a0bac2fe6222964b098cfaf9470f09c43328fcf5..09e40d6e50b7c1ddd1451981d05ecbbe | |
this.player.swing(enumhand, true); | ||
} | ||
} | ||
@@ -2392,13 +2392,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl | ||
@@ -2387,13 +2387,20 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl | ||
double d3 = Math.max(this.player.blockInteractionRange(), this.player.entityInteractionRange()); | ||
// SPIGOT-5607: Only call interact event if no block or entity is being clicked. Use bukkit ray trace method, because it handles blocks and entities at the same time | ||
// SPIGOT-7429: Make sure to call PlayerInteractEvent for spectators and non-pickable entities | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.