SPIGOT-6524: Inventory desync when InventoryClickEvent is cancelled

This commit is contained in:
md_5 2021-06-12 19:44:31 +10:00
parent eeae1b1995
commit cfe7fecf3e
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -1235,7 +1235,7 @@
} else { } else {
PlayerConnection.this.disconnect(new ChatMessage("multiplayer.disconnect.invalid_entity_attacked")); 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()); PlayerConnection.LOGGER.warn("Player {} tried to attack an invalid entity", PlayerConnection.this.player.getDisplayName().getString());
@@ -1409,19 +2147,303 @@ @@ -1409,19 +2147,302 @@
@Override @Override
public void a(PacketPlayInCloseWindow packetplayinclosewindow) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinclosewindow, this, this.player.getWorldServer());
@ -1529,7 +1529,6 @@
+ case NOTHING: + case NOTHING:
+ break; + break;
+ } + }
+ return;
+ } + }
+ +
+ if (event instanceof CraftItemEvent || event instanceof SmithItemEvent) { + if (event instanceof CraftItemEvent || event instanceof SmithItemEvent) {
@ -1542,7 +1541,7 @@
ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.f()).iterator(); ObjectIterator objectiterator = Int2ObjectMaps.fastIterable(packetplayinwindowclick.f()).iterator();
while (objectiterator.hasNext()) { while (objectiterator.hasNext()) {
@@ -1452,6 +2474,7 @@ @@ -1452,6 +2473,7 @@
@Override @Override
public void a(PacketPlayInEnchantItem packetplayinenchantitem) { public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinenchantitem, this, this.player.getWorldServer());
@ -1550,7 +1549,7 @@
this.player.resetIdleTimer(); this.player.resetIdleTimer();
if (this.player.containerMenu.containerId == packetplayinenchantitem.b() && !this.player.isSpectator()) { if (this.player.containerMenu.containerId == packetplayinenchantitem.b() && !this.player.isSpectator()) {
this.player.containerMenu.a((EntityHuman) this.player, packetplayinenchantitem.c()); this.player.containerMenu.a((EntityHuman) this.player, packetplayinenchantitem.c());
@@ -1484,6 +2507,43 @@ @@ -1484,6 +2506,43 @@
boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45; boolean flag1 = packetplayinsetcreativeslot.b() >= 1 && packetplayinsetcreativeslot.b() <= 45;
boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty(); boolean flag2 = itemstack.isEmpty() || itemstack.getDamage() >= 0 && itemstack.getCount() <= 64 && !itemstack.isEmpty();
@ -1594,7 +1593,7 @@
if (flag1 && flag2) { if (flag1 && flag2) {
if (itemstack.isEmpty()) { if (itemstack.isEmpty()) {
@@ -1511,6 +2571,7 @@ @@ -1511,6 +2570,7 @@
} }
private void a(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) { private void a(PacketPlayInUpdateSign packetplayinupdatesign, List<ITextFilter.a> list) {
@ -1602,7 +1601,7 @@
this.player.resetIdleTimer(); this.player.resetIdleTimer();
WorldServer worldserver = this.player.getWorldServer(); WorldServer worldserver = this.player.getWorldServer();
BlockPosition blockposition = packetplayinupdatesign.b(); BlockPosition blockposition = packetplayinupdatesign.b();
@@ -1527,18 +2588,37 @@ @@ -1527,18 +2587,37 @@
if (!tileentitysign.d() || !this.player.getUniqueID().equals(tileentitysign.f())) { if (!tileentitysign.d() || !this.player.getUniqueID().equals(tileentitysign.f())) {
PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString()); PlayerConnection.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getDisplayName().getString());
@ -1642,7 +1641,7 @@
tileentitysign.update(); tileentitysign.update();
worldserver.notify(blockposition, iblockdata, iblockdata, 3); worldserver.notify(blockposition, iblockdata, iblockdata, 3);
@@ -1548,6 +2628,7 @@ @@ -1548,6 +2627,7 @@
@Override @Override
public void a(PacketPlayInKeepAlive packetplayinkeepalive) { public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
@ -1650,7 +1649,7 @@
if (this.keepAlivePending && packetplayinkeepalive.b() == this.keepAliveChallenge) { if (this.keepAlivePending && packetplayinkeepalive.b() == this.keepAliveChallenge) {
int i = (int) (SystemUtils.getMonotonicMillis() - this.keepAliveTime); int i = (int) (SystemUtils.getMonotonicMillis() - this.keepAliveTime);
@@ -1562,7 +2643,17 @@ @@ -1562,7 +2642,17 @@
@Override @Override
public void a(PacketPlayInAbilities packetplayinabilities) { public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer()); PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.getWorldServer());
@ -1669,7 +1668,7 @@
} }
@Override @Override
@@ -1571,8 +2662,50 @@ @@ -1571,8 +2661,50 @@
this.player.a(packetplayinsettings); this.player.a(packetplayinsettings);
} }