mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@c95bc5f Don't unpack loot table for TEs not in world (#9918) PaperMC/Paper@6675d13 Fix strikeLightningEffect powers lightning rods & clears copper (#9780) PaperMC/Paper@63e77b5 Add Enchantment cost API (#9856) PaperMC/Paper@d8847bc Updated Upstream (Bukkit/CraftBukkit) (#9922) PaperMC/Paper@dd47ec6 Add Entity Movement Direction API (#7085) PaperMC/Paper@9ee60ec Add aggressive mob API (#9838) PaperMC/Paper@531ef27 Use ApiStatus.Internal instead of Deprecated (#9042) PaperMC/Paper@9548629 Add hand to fish event for all player interactions (#9929) PaperMC/Paper@aee3830 Deprecate Material#isInteractable (#9216) PaperMC/Paper@a506b48 Fix several issues with EntityBreedEvent (#8677) PaperMC/Paper@f186318 Run the chat callback on the main thread as expected (#9935)
35 lines
2.9 KiB
Diff
35 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Wed, 23 Dec 2020 00:43:59 -0600
|
|
Subject: [PATCH] PlayerBookTooLargeEvent
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 93b81303c6f5a009af7c282435671fd05ca68499..8ed7699d2f8b636cce023c1afe0e196c8361725c 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1149,10 +1149,15 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
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));
|
|
long byteAllowed = maxBookPageSize;
|
|
+ // Purpur start
|
|
+ int slot = packet.getSlot();
|
|
+ ItemStack itemstack = Inventory.isHotbarSlot(slot) || slot == Inventory.SLOT_OFFHAND ? this.player.getInventory().getItem(slot) : ItemStack.EMPTY;
|
|
+ // Purpur end
|
|
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!");
|
|
+ org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent event = new org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent(player.getBukkitEntity(), itemstack.asBukkitCopy()); if (event.shouldKickPlayer()) // Purpur
|
|
server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause
|
|
return;
|
|
}
|
|
@@ -1176,6 +1181,7 @@ 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());
|
|
+ org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent event = new org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent(player.getBukkitEntity(), itemstack.asBukkitCopy()); if (event.shouldKickPlayer()) // Purpur
|
|
server.scheduleOnMain(() -> this.disconnect("Book too large!", org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION)); // Paper - kick event cause
|
|
return;
|
|
}
|