mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 02:35:49 +01:00
Fix missing PlayerEditBookEvent
By: md_5 <git@md-5.net>
This commit is contained in:
parent
8797975de5
commit
544ec40369
1 changed files with 58 additions and 39 deletions
|
@ -379,16 +379,27 @@
|
|||
int i = packetplayinbedit.d();
|
||||
|
||||
if (PlayerInventory.d(i) || i == 40) {
|
||||
@@ -787,7 +1008,7 @@
|
||||
this.a(list, (s) -> {
|
||||
return IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) (new ChatComponentText(s)));
|
||||
}, itemstack1);
|
||||
- this.player.getInventory().setItem(i, itemstack1);
|
||||
+ this.player.getInventory().setItem(i, CraftEventFactory.handleEditBookEvent(player, i, itemstack, itemstack1)); // CraftBukkit
|
||||
@@ -761,7 +982,7 @@
|
||||
ItemStack itemstack = this.player.getInventory().getItem(i);
|
||||
|
||||
if (itemstack.a(Items.WRITABLE_BOOK)) {
|
||||
- this.a(list, UnaryOperator.identity(), itemstack);
|
||||
+ this.a(list, UnaryOperator.identity(), itemstack, i, itemstack.cloneItemStack()); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -795,7 +1016,7 @@
|
||||
@@ -786,16 +1007,16 @@
|
||||
|
||||
this.a(list, (s) -> {
|
||||
return IChatBaseComponent.ChatSerializer.a((IChatBaseComponent) (new ChatComponentText(s)));
|
||||
- }, itemstack1);
|
||||
+ }, itemstack1, i, itemstack); // CraftBukkit
|
||||
this.player.getInventory().setItem(i, itemstack1);
|
||||
}
|
||||
}
|
||||
|
||||
- private void a(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack) {
|
||||
+ private void a(List<ITextFilter.a> list, UnaryOperator<String> unaryoperator, ItemStack itemstack, int slot, ItemStack old) { // CraftBukkit
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
|
||||
if (this.player.R()) {
|
||||
|
@ -397,7 +408,15 @@
|
|||
return NBTTagString.a((String) unaryoperator.apply(itextfilter_a.b()));
|
||||
});
|
||||
|
||||
@@ -859,7 +1080,7 @@
|
||||
@@ -823,6 +1044,7 @@
|
||||
}
|
||||
|
||||
itemstack.a("pages", (NBTBase) nbttaglist);
|
||||
+ CraftEventFactory.handleEditBookEvent(player, slot, old, itemstack); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -859,7 +1081,7 @@
|
||||
} else {
|
||||
WorldServer worldserver = this.player.getWorldServer();
|
||||
|
||||
|
@ -406,7 +425,7 @@
|
|||
if (this.tickCount == 0) {
|
||||
this.syncPosition();
|
||||
}
|
||||
@@ -869,7 +1090,7 @@
|
||||
@@ -869,7 +1091,7 @@
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.b(this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, this.player.getYRot(), this.player.getXRot());
|
||||
}
|
||||
|
@ -415,7 +434,7 @@
|
|||
} else {
|
||||
this.awaitingTeleportTime = this.tickCount;
|
||||
double d0 = a(packetplayinflying.a(this.player.locX()));
|
||||
@@ -881,7 +1102,15 @@
|
||||
@@ -881,7 +1103,15 @@
|
||||
if (this.player.isPassenger()) {
|
||||
this.player.setLocation(this.player.locX(), this.player.locY(), this.player.locZ(), f, f1);
|
||||
this.player.getWorldServer().getChunkProvider().movePlayer(this.player);
|
||||
|
@ -431,7 +450,7 @@
|
|||
double d3 = this.player.locX();
|
||||
double d4 = this.player.locY();
|
||||
double d5 = this.player.locZ();
|
||||
@@ -901,15 +1130,33 @@
|
||||
@@ -901,15 +1131,33 @@
|
||||
++this.receivedMovePacketCount;
|
||||
int i = this.receivedMovePacketCount - this.knownMovePacketCount;
|
||||
|
||||
|
@ -467,7 +486,7 @@
|
|||
PlayerConnection.LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getDisplayName().getString(), d7, d8, d9);
|
||||
this.b(this.player.locX(), this.player.locY(), this.player.locZ(), this.player.getYRot(), this.player.getXRot());
|
||||
return;
|
||||
@@ -928,6 +1175,7 @@
|
||||
@@ -928,6 +1176,7 @@
|
||||
}
|
||||
|
||||
this.player.move(EnumMoveType.PLAYER, new Vec3D(d7, d8, d9));
|
||||
|
@ -475,7 +494,7 @@
|
|||
double d12 = d8;
|
||||
|
||||
d7 = d0 - this.player.locX();
|
||||
@@ -949,10 +1197,74 @@
|
||||
@@ -949,10 +1198,74 @@
|
||||
if (!this.player.noPhysics && !this.player.isSleeping() && (flag1 && worldserver.getCubes(this.player, axisalignedbb) || this.a((IWorldReader) worldserver, axisalignedbb))) {
|
||||
this.b(d3, d4, d5, f, f1);
|
||||
} else {
|
||||
|
@ -552,7 +571,7 @@
|
|||
if (flag) {
|
||||
this.player.fallDistance = 0.0F;
|
||||
}
|
||||
@@ -980,19 +1292,80 @@
|
||||
@@ -980,19 +1293,80 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -637,7 +656,7 @@
|
|||
double d3 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.X) ? this.player.locX() : 0.0D;
|
||||
double d4 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Y) ? this.player.locY() : 0.0D;
|
||||
double d5 = set.contains(PacketPlayOutPosition.EnumPlayerTeleportFlags.Z) ? this.player.locZ() : 0.0D;
|
||||
@@ -1004,6 +1377,14 @@
|
||||
@@ -1004,6 +1378,14 @@
|
||||
this.awaitingTeleport = 0;
|
||||
}
|
||||
|
||||
|
@ -652,7 +671,7 @@
|
|||
this.awaitingTeleportTime = this.tickCount;
|
||||
this.player.setLocation(d0, d1, d2, f, f1);
|
||||
this.player.connection.sendPacket(new PacketPlayOutPosition(d0 - d3, d1 - d4, d2 - d5, f - f2, f1 - f3, set, this.awaitingTeleport, flag));
|
||||
@@ -1012,6 +1393,7 @@
|
||||
@@ -1012,6 +1394,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInBlockDig packetplayinblockdig) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinblockdig, this, this.player.getWorldServer());
|
||||
|
@ -660,7 +679,7 @@
|
|||
BlockPosition blockposition = packetplayinblockdig.b();
|
||||
|
||||
this.player.resetIdleTimer();
|
||||
@@ -1022,14 +1404,46 @@
|
||||
@@ -1022,14 +1405,46 @@
|
||||
if (!this.player.isSpectator()) {
|
||||
ItemStack itemstack = this.player.b(EnumHand.OFF_HAND);
|
||||
|
||||
|
@ -709,7 +728,7 @@
|
|||
this.player.dropItem(false);
|
||||
}
|
||||
|
||||
@@ -1066,6 +1480,7 @@
|
||||
@@ -1066,6 +1481,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInUseItem packetplayinuseitem) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseitem, this, this.player.getWorldServer());
|
||||
|
@ -717,7 +736,7 @@
|
|||
WorldServer worldserver = this.player.getWorldServer();
|
||||
EnumHand enumhand = packetplayinuseitem.b();
|
||||
ItemStack itemstack = this.player.b(enumhand);
|
||||
@@ -1078,6 +1493,14 @@
|
||||
@@ -1078,6 +1494,14 @@
|
||||
|
||||
if (blockposition.getY() < i) {
|
||||
if (this.awaitingPositionFromClient == null && this.player.h((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D) < 64.0D && worldserver.a((EntityHuman) this.player, blockposition)) {
|
||||
|
@ -732,7 +751,7 @@
|
|||
EnumInteractionResult enuminteractionresult = this.player.gameMode.a(this.player, worldserver, itemstack, enumhand, movingobjectpositionblock);
|
||||
|
||||
if (enumdirection == EnumDirection.UP && !enuminteractionresult.a() && blockposition.getY() >= i - 1 && a(this.player, itemstack)) {
|
||||
@@ -1101,12 +1524,51 @@
|
||||
@@ -1101,12 +1525,51 @@
|
||||
@Override
|
||||
public void a(PacketPlayInBlockPlace packetplayinblockplace) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinblockplace, this, this.player.getWorldServer());
|
||||
|
@ -784,7 +803,7 @@
|
|||
EnumInteractionResult enuminteractionresult = this.player.gameMode.a(this.player, worldserver, itemstack, enumhand);
|
||||
|
||||
if (enuminteractionresult.b()) {
|
||||
@@ -1127,7 +1589,7 @@
|
||||
@@ -1127,7 +1590,7 @@
|
||||
Entity entity = packetplayinspectate.a(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
|
@ -793,7 +812,7 @@
|
|||
return;
|
||||
}
|
||||
}
|
||||
@@ -1142,6 +1604,7 @@
|
||||
@@ -1142,6 +1605,7 @@
|
||||
PlayerConnection.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getDisplayName());
|
||||
this.disconnect(new ChatMessage("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
}
|
||||
|
@ -801,7 +820,7 @@
|
|||
|
||||
}
|
||||
|
||||
@@ -1161,11 +1624,26 @@
|
||||
@@ -1161,11 +1625,26 @@
|
||||
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent) {
|
||||
|
@ -829,7 +848,7 @@
|
|||
this.player.Q().b();
|
||||
if (this.isExemptPlayer()) {
|
||||
PlayerConnection.LOGGER.info("Stopping singleplayer server as player logged out");
|
||||
@@ -1180,6 +1658,15 @@
|
||||
@@ -1180,6 +1659,15 @@
|
||||
}
|
||||
|
||||
public void a(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
|
||||
|
@ -845,7 +864,7 @@
|
|||
try {
|
||||
this.connection.sendPacket(packet, genericfuturelistener);
|
||||
} catch (Throwable throwable) {
|
||||
@@ -1196,7 +1683,16 @@
|
||||
@@ -1196,7 +1684,16 @@
|
||||
@Override
|
||||
public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
|
||||
|
@ -862,7 +881,7 @@
|
|||
if (this.player.getInventory().selected != packetplayinhelditemslot.b() && this.player.getRaisedHand() == EnumHand.MAIN_HAND) {
|
||||
this.player.clearActiveItem();
|
||||
}
|
||||
@@ -1205,11 +1701,18 @@
|
||||
@@ -1205,11 +1702,18 @@
|
||||
this.player.resetIdleTimer();
|
||||
} else {
|
||||
PlayerConnection.LOGGER.warn("{} tried to set an invalid carried item", this.player.getDisplayName().getString());
|
||||
|
@ -881,7 +900,7 @@
|
|||
String s = StringUtils.normalizeSpace(packetplayinchat.b());
|
||||
|
||||
for (int i = 0; i < s.length(); ++i) {
|
||||
@@ -1223,20 +1726,42 @@
|
||||
@@ -1223,20 +1727,42 @@
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinchat, this, this.player.getWorldServer());
|
||||
this.a(ITextFilter.a.a(s));
|
||||
} else {
|
||||
|
@ -928,7 +947,7 @@
|
|||
} else {
|
||||
String s1 = itextfilter_a.b();
|
||||
ChatMessage chatmessage = s1.isEmpty() ? null : new ChatMessage("chat.type.text", new Object[]{this.player.getScoreboardDisplayName(), s1});
|
||||
@@ -1247,28 +1772,198 @@
|
||||
@@ -1247,28 +1773,198 @@
|
||||
}, ChatMessageType.CHAT, this.player.getUniqueID());
|
||||
}
|
||||
|
||||
|
@ -1131,7 +1150,7 @@
|
|||
this.player.resetIdleTimer();
|
||||
IJumpable ijumpable;
|
||||
|
||||
@@ -1326,6 +2021,7 @@
|
||||
@@ -1326,6 +2022,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInUseEntity packetplayinuseentity) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinuseentity, this, this.player.getWorldServer());
|
||||
|
@ -1139,7 +1158,7 @@
|
|||
WorldServer worldserver = this.player.getWorldServer();
|
||||
final Entity entity = packetplayinuseentity.a(worldserver);
|
||||
|
||||
@@ -1336,10 +2032,44 @@
|
||||
@@ -1336,10 +2033,44 @@
|
||||
|
||||
if (this.player.f(entity) < 36.0D) {
|
||||
packetplayinuseentity.a(new PacketPlayInUseEntity.c() {
|
||||
|
@ -1185,7 +1204,7 @@
|
|||
if (enuminteractionresult.a()) {
|
||||
CriterionTriggers.PLAYER_INTERACTED_WITH_ENTITY.a(PlayerConnection.this.player, itemstack, entity);
|
||||
if (enuminteractionresult.b()) {
|
||||
@@ -1351,20 +2081,27 @@
|
||||
@@ -1351,20 +2082,27 @@
|
||||
|
||||
@Override
|
||||
public void a(EnumHand enumhand) {
|
||||
|
@ -1216,7 +1235,7 @@
|
|||
} else {
|
||||
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked"));
|
||||
PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getDisplayName().getString());
|
||||
@@ -1409,19 +2146,303 @@
|
||||
@@ -1409,19 +2147,303 @@
|
||||
@Override
|
||||
public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
|
||||
|
@ -1523,7 +1542,7 @@
|
|||
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.f()).iterator();
|
||||
|
||||
while (objectiterator.hasNext()) {
|
||||
@@ -1452,6 +2473,7 @@
|
||||
@@ -1452,6 +2474,7 @@
|
||||
@Override
|
||||
public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
|
||||
|
@ -1531,7 +1550,7 @@
|
|||
this.player.resetIdleTimer();
|
||||
if (this.player.containerMenu.containerId == packetplayinenchantitem.b() && !this.player.isSpectator()) {
|
||||
this.player.containerMenu.a((EntityHuman) this.player, packetplayinenchantitem.c());
|
||||
@@ -1484,6 +2506,43 @@
|
||||
@@ -1484,6 +2507,43 @@
|
||||
|
||||
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
|
||||
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
|
||||
|
@ -1575,7 +1594,7 @@
|
|||
|
||||
if (flag1 && flag2) {
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -1511,6 +2570,7 @@
|
||||
@@ -1511,6 +2571,7 @@
|
||||
}
|
||||
|
||||
private void a(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
|
||||
|
@ -1583,7 +1602,7 @@
|
|||
this.player.resetIdleTimer();
|
||||
WorldServer worldserver = this.player.getWorldServer();
|
||||
BlockPosition blockposition = packetplayinupdatesign.b();
|
||||
@@ -1527,18 +2587,37 @@
|
||||
@@ -1527,18 +2588,37 @@
|
||||
|
||||
if (!tileentitysign.d() || !this.player.getUniqueID().equals(tileentitysign.f())) {
|
||||
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString());
|
||||
|
@ -1623,7 +1642,7 @@
|
|||
|
||||
tileentitysign.update();
|
||||
worldserver.notify(blockposition, iblockdata, iblockdata, 3);
|
||||
@@ -1548,6 +2627,7 @@
|
||||
@@ -1548,6 +2628,7 @@
|
||||
|
||||
@Override
|
||||
public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
|
||||
|
@ -1631,7 +1650,7 @@
|
|||
if (this.keepAlivePending && packetplayinkeepalive.b() == this.keepAliveChallenge) {
|
||||
int i = (int) (SystemUtils.getMonotonicMillis() - this.keepAliveTime);
|
||||
|
||||
@@ -1562,7 +2642,17 @@
|
||||
@@ -1562,7 +2643,17 @@
|
||||
@Override
|
||||
public void a(PacketPlayInAbilities packetplayinabilities) {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
|
||||
|
@ -1650,7 +1669,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -1571,8 +2661,50 @@
|
||||
@@ -1571,8 +2662,50 @@
|
||||
this.player.a(packetplayinsettings);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue