mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 17:37:42 +01:00
PlayerBookTooLargeEvent
This commit is contained in:
committed by
granny
parent
5110e3635e
commit
54eca0d36a
@@ -62,10 +62,10 @@ index 5b50bc97ccab73dcafa29e3a8c5d04b3c4e8c1d4..c03639557e498f44a53fbf223928f68e
|
||||
|
||||
private void updatePlayerAttributes() {
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index db9860c44faacdf4b24979c2ffa84515e3883299..1fc37692c7ddfc7b7e0961cd9f0602339f18a2df 100644
|
||||
index 0c184da09628c0f2fd21e4cacd3ab6ae74f11e64..e569a1e0c282e43410ad321790114acc05bb2ad0 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2795,6 +2795,8 @@ public class ServerGamePacketListenerImpl
|
||||
@@ -2800,6 +2800,8 @@ public class ServerGamePacketListenerImpl
|
||||
|
||||
ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event);
|
||||
|
||||
|
||||
@@ -43,6 +43,27 @@
|
||||
Location oldTo = to.clone();
|
||||
PlayerMoveEvent event = new PlayerMoveEvent(player, from, to);
|
||||
this.cserver.getPluginManager().callEvent(event);
|
||||
@@ -1169,6 +_,10 @@
|
||||
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;
|
||||
+ // Purpur start - PlayerBookTooLargeEvent
|
||||
+ int slot = packet.slot();
|
||||
+ ItemStack itemstack = Inventory.isHotbarSlot(slot) || slot == Inventory.SLOT_OFFHAND ? this.player.getInventory().getItem(slot) : ItemStack.EMPTY;
|
||||
+ // Purpur end - PlayerBookTooLargeEvent
|
||||
for (final String page : pageList) {
|
||||
final int byteLength = page.getBytes(java.nio.charset.StandardCharsets.UTF_8).length;
|
||||
byteTotal += byteLength;
|
||||
@@ -1193,7 +_,8 @@
|
||||
}
|
||||
|
||||
if (byteTotal > byteAllowed) {
|
||||
- ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send a book too large. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size());
|
||||
+ ServerGamePacketListenerImpl.LOGGER.warn("{} tried to send too large of a book. Book size: {} - Allowed: {} - Pages: {}", this.player.getScoreboardName(), byteTotal, byteAllowed, pageList.size());
|
||||
+ org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent event = new org.purpurmc.purpur.event.player.PlayerBookTooLargeEvent(player.getBukkitEntity(), itemstack.asBukkitCopy()); if (event.shouldKickPlayer()) // Purpur - PlayerBookTooLargeEvent
|
||||
this.disconnectAsync(Component.literal("Book too large!"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause // Paper - add proper async disconnect
|
||||
return;
|
||||
}
|
||||
@@ -1212,31 +_,45 @@
|
||||
Optional<String> optional = packet.title();
|
||||
optional.ifPresent(list::add);
|
||||
|
||||
Reference in New Issue
Block a user