mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
Remove arbitrary book page limit (#11228)
This commit is contained in:
parent
794e2754b5
commit
4c7b6f5c05
3 changed files with 18 additions and 19 deletions
|
@ -285,18 +285,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
|
this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed
|
||||||
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
@@ -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) {
|
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!"));
|
||||||
+ this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
+ this.disconnect(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Aikar <aikar@aikar.co>
|
From: Aikar <aikar@aikar.co>
|
||||||
Date: Fri, 16 Nov 2018 23:08:50 -0500
|
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.
|
Puts some limits on the size of books.
|
||||||
|
|
||||||
|
@ -18,15 +18,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ List<String> pageList = packet.pages();
|
+ List<String> pageList = packet.pages();
|
||||||
+ long byteTotal = 0;
|
+ long byteTotal = 0;
|
||||||
+ int maxBookPageSize = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax;
|
+ 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;
|
+ long byteAllowed = maxBookPageSize;
|
||||||
+ for (String testString : pageList) {
|
+ for (String testString : pageList) {
|
||||||
+ int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
|
+ 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;
|
+ byteTotal += byteLength;
|
||||||
+ int length = testString.length();
|
+ int length = testString.length();
|
||||||
+ int multibytes = 0;
|
+ 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) {
|
+ if (multibytes > 1) {
|
||||||
+ // penalize MB
|
+ // penalize MB
|
||||||
|
@ -46,7 +41,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (byteTotal > byteAllowed) {
|
+ 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!"));
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
|
@ -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
|
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
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
--- a/src/main/java/net/minecraft/network/chat/contents/TranslatableContents.java
|
||||||
|
|
Loading…
Reference in a new issue