Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
Fix PlayerEditBookEvent
Dieser Commit ist enthalten in:
Ursprung
f4e3b4e439
Commit
5cdbb30e78
35
Spigot-Server-Patches/0415-Fix-PlayerEditBookEvent.patch
Normale Datei
35
Spigot-Server-Patches/0415-Fix-PlayerEditBookEvent.patch
Normale Datei
@ -0,0 +1,35 @@
|
||||
From 0c0ee91d52bacd3d616fedf173cf2684a90d4c50 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Himing <mhiming@gmail.com>
|
||||
Date: Sun, 16 Dec 2018 13:07:33 +1100
|
||||
Subject: [PATCH] Fix PlayerEditBookEvent
|
||||
|
||||
- Updating book writing (not signing) mutated the original item, making
|
||||
it impossible to properly cancel the event or modify the book meta
|
||||
|
||||
- When the event was cancelled, the client's book would keep the
|
||||
cancelled writing
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 74c570615..616dbb152 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -816,10 +816,13 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
||||
this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, itemstack2)); // CraftBukkit
|
||||
} else {
|
||||
- ItemStack old = itemstack1.cloneItemStack(); // CraftBukkit
|
||||
- itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
|
||||
- CraftEventFactory.handleEditBookEvent(player, enumitemslot, old, itemstack1); // CraftBukkit
|
||||
+ // Paper start - dont mutate players current item, set it from the event
|
||||
+ ItemStack newBook = itemstack1.cloneItemStack();
|
||||
+ newBook.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
|
||||
+ this.player.setSlot(enumitemslot, CraftEventFactory.handleEditBookEvent(player, enumitemslot, itemstack1, newBook));
|
||||
+ // Paper end
|
||||
}
|
||||
+ player.getBukkitEntity().updateInventory(); // Paper - fix client desync when event is cancelled
|
||||
}
|
||||
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren