SPIGOT-3987: Preserve attributes when writing in books

This commit is contained in:
md_5 2018-07-08 10:25:17 +10:00
parent 6103339c08
commit ab13683d8e

View File

@ -1593,11 +1593,9 @@
packetdataserializer = packetplayincustompayload.b(); packetdataserializer = packetplayincustompayload.b();
try { try {
@@ -1064,15 +2166,25 @@ @@ -1065,14 +2167,23 @@
}
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
+ itemstack1 = new ItemStack(Items.WRITABLE_BOOK); // CraftBukkit
itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8)); itemstack1.a("pages", (NBTBase) itemstack.getTag().getList("pages", 8));
+ CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit + CraftEventFactory.handleEditBookEvent(player, itemstack1); // CraftBukkit
} }
@ -1619,7 +1617,7 @@
packetdataserializer = packetplayincustompayload.b(); packetdataserializer = packetplayincustompayload.b();
try { try {
@@ -1106,10 +2218,11 @@ @@ -1106,10 +2217,11 @@
} }
itemstack2.a("pages", (NBTBase) nbttaglist); itemstack2.a("pages", (NBTBase) nbttaglist);
@ -1632,7 +1630,7 @@
} }
} else if ("MC|TrSel".equals(s)) { } else if ("MC|TrSel".equals(s)) {
try { try {
@@ -1121,6 +2234,7 @@ @@ -1121,6 +2233,7 @@
} }
} catch (Exception exception2) { } catch (Exception exception2) {
PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2); PlayerConnection.LOGGER.error("Couldn\'t select trade", exception2);
@ -1640,7 +1638,7 @@
} }
} else { } else {
TileEntity tileentity; TileEntity tileentity;
@@ -1170,6 +2284,7 @@ @@ -1170,6 +2283,7 @@
} }
} catch (Exception exception3) { } catch (Exception exception3) {
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3); PlayerConnection.LOGGER.error("Couldn\'t set command block", exception3);
@ -1648,7 +1646,7 @@
} }
} else if ("MC|AutoCmd".equals(s)) { } else if ("MC|AutoCmd".equals(s)) {
if (!this.minecraftServer.getEnableCommandBlock()) { if (!this.minecraftServer.getEnableCommandBlock()) {
@@ -1237,6 +2352,7 @@ @@ -1237,6 +2351,7 @@
} }
} catch (Exception exception4) { } catch (Exception exception4) {
PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4); PlayerConnection.LOGGER.error("Couldn\'t set command block", exception4);
@ -1656,7 +1654,7 @@
} }
} else { } else {
int k; int k;
@@ -1260,6 +2376,7 @@ @@ -1260,6 +2375,7 @@
} }
} catch (Exception exception5) { } catch (Exception exception5) {
PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5); PlayerConnection.LOGGER.error("Couldn\'t set beacon", exception5);
@ -1664,7 +1662,7 @@
} }
} }
} else if ("MC|ItemName".equals(s)) { } else if ("MC|ItemName".equals(s)) {
@@ -1346,6 +2463,7 @@ @@ -1346,6 +2462,7 @@
} }
} catch (Exception exception6) { } catch (Exception exception6) {
PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6); PlayerConnection.LOGGER.error("Couldn\'t set structure block", exception6);
@ -1672,7 +1670,7 @@
} }
} else if ("MC|PickItem".equals(s)) { } else if ("MC|PickItem".equals(s)) {
packetdataserializer = packetplayincustompayload.b(); packetdataserializer = packetplayincustompayload.b();
@@ -1358,11 +2476,49 @@ @@ -1358,11 +2475,49 @@
this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); this.player.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex));
} catch (Exception exception7) { } catch (Exception exception7) {
PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7); PlayerConnection.LOGGER.error("Couldn\'t pick item", exception7);