Fix PlayerEditBookEvent (#5463)
This commit is contained in:
parent
3fea87edb3
commit
dc529c7a93
2 changed files with 38 additions and 0 deletions
|
@ -0,0 +1,19 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jmp <jasonpenilla2@me.com>
|
||||||
|
Date: Mon, 5 Apr 2021 18:35:37 -0700
|
||||||
|
Subject: [PATCH] Allow PlayerEditBookEvent to fire for off hand
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java b/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java
|
||||||
|
index c8fda418bd5e0e6c299900be469862dbc5d7a56f..b8994a6d023c124f2c068d2e69f2c3d949b9405e 100644
|
||||||
|
--- a/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java
|
||||||
|
+++ b/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java
|
||||||
|
@@ -24,7 +24,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable {
|
||||||
|
public PlayerEditBookEvent(@NotNull Player who, int slot, @NotNull BookMeta previousBookMeta, @NotNull BookMeta newBookMeta, boolean isSigning) {
|
||||||
|
super(who);
|
||||||
|
|
||||||
|
- Validate.isTrue(slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive");
|
||||||
|
+ Validate.isTrue(slot == 40 || slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive"); // Paper - off hand is 40
|
||||||
|
Validate.notNull(previousBookMeta, "Previous book meta must not be null");
|
||||||
|
Validate.notNull(newBookMeta, "New book meta must not be null");
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jmp <jasonpenilla2@me.com>
|
||||||
|
Date: Mon, 5 Apr 2021 18:35:15 -0700
|
||||||
|
Subject: [PATCH] Don't ignore result of PlayerEditBookEvent
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
||||||
|
index 5ee56f3636b299280a7c2bc5a210c63250a47fb3..e6ea84ba098b4d77bc68e99862992a10ef4585b5 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
||||||
|
@@ -1144,7 +1144,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||||
|
list.stream().map(NBTTagString::a).forEach(nbttaglist::add);
|
||||||
|
ItemStack old = itemstack.cloneItemStack(); // CraftBukkit
|
||||||
|
itemstack.a("pages", (NBTBase) nbttaglist);
|
||||||
|
- CraftEventFactory.handleEditBookEvent(player, i, old, itemstack); // CraftBukkit
|
||||||
|
+ this.player.inventory.setItem(i, CraftEventFactory.handleEditBookEvent(player, i, old, itemstack)); // CraftBukkit // Paper - Don't ignore result (see other callsite for handleEditBookEvent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue