Skip Improve-exact-choice-recipe-ingredients for now
This commit is contained in:
parent
8851d25a4d
commit
f677393a88
27 changed files with 129 additions and 158 deletions
56
patches/server/0268-Book-size-limits.patch
Normal file
56
patches/server/0268-Book-size-limits.patch
Normal file
|
@ -0,0 +1,56 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 16 Nov 2018 23:08:50 -0500
|
||||
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 5b5c5864fa1ad96946b0892998284fab26e54095..9c04eb00c80a343502ece3001a6b21382d011d30 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1049,6 +1049,44 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
@Override
|
||||
public void handleEditBook(ServerboundEditBookPacket packet) {
|
||||
+ // Paper start - Book size limits
|
||||
+ final io.papermc.paper.configuration.type.number.IntOr.Disabled pageMax = io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.pageMax;
|
||||
+ if (!this.cserver.isPrimaryThread() && pageMax.enabled()) {
|
||||
+ final List<String> pageList = packet.pages();
|
||||
+ long byteTotal = 0;
|
||||
+ final int maxBookPageSize = pageMax.intValue();
|
||||
+ final double multiplier = Math.clamp(io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.bookSize.totalMultiplier, 0.3D, 1D);
|
||||
+ long byteAllowed = maxBookPageSize;
|
||||
+ for (final String page : pageList) {
|
||||
+ final int byteLength = page.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
|
||||
+ byteTotal += byteLength;
|
||||
+ final int length = page.length();
|
||||
+ int multiByteCharacters = 0;
|
||||
+ if (byteLength != length) {
|
||||
+ // Count the number of multi byte characters
|
||||
+ for (final char c : page.toCharArray()) {
|
||||
+ if (c > 127) {
|
||||
+ multiByteCharacters++;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Allow pages with fewer characters to consume less of the allowed byte quota
|
||||
+ byteAllowed += maxBookPageSize * Math.clamp((double) length / 255D, 0.1D, 1) * multiplier;
|
||||
+
|
||||
+ if (multiByteCharacters > 1) {
|
||||
+ // Penalize multibyte characters
|
||||
+ byteAllowed -= multiByteCharacters;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (byteTotal > byteAllowed) {
|
||||
+ 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;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - Book size limits
|
||||
// CraftBukkit start
|
||||
if (this.lastBookTick + 20 > MinecraftServer.currentTick) {
|
||||
this.disconnect(Component.literal("Book edited too quickly!"));
|
Loading…
Add table
Add a link
Reference in a new issue