From d4eaf226f97d66f35f4a62bf07626646ea2ec0b0 Mon Sep 17 00:00:00 2001 From: Thinkofdeath Date: Sun, 4 Jan 2015 20:23:54 +0000 Subject: SPIGOT-270: Fire inventory events for spectator mode (but cancelled) --- nms-patches/PlayerConnection.patch | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'nms-patches/PlayerConnection.patch') diff --git a/nms-patches/PlayerConnection.patch b/nms-patches/PlayerConnection.patch index 358962f2..28a90bfe 100644 --- a/nms-patches/PlayerConnection.patch +++ b/nms-patches/PlayerConnection.patch @@ -1,5 +1,5 @@ ---- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2015-01-04 20:11:55.473664041 +0000 -+++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-01-04 20:11:55.473664041 +0000 +--- ../work/decompile-8eb82bde//net/minecraft/server/PlayerConnection.java 2015-01-04 20:23:44.409656346 +0000 ++++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-01-04 20:23:44.413656346 +0000 @@ -16,6 +16,48 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -946,7 +946,7 @@ } else if (this.player.u().getWorldData().isHardcore()) { if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { this.player.playerConnection.disconnect("You have died. Game over, man, it\'s game over!"); -@@ -694,11 +1295,17 @@ +@@ -694,15 +1295,22 @@ } public void a(PacketPlayInCloseWindow packetplayinclosewindow) { @@ -964,7 +964,13 @@ PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u()); this.player.z(); if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { -@@ -711,7 +1318,269 @@ +- if (this.player.v()) { ++ boolean cancelled = this.player.v(); // CraftBukkit - see below if ++ if (false) { // CraftBukkit this.player.v()) { + ArrayList arraylist = Lists.newArrayList(); + + for (int i = 0; i < this.player.activeContainer.c.size(); ++i) { +@@ -711,7 +1319,270 @@ this.player.a(this.player.activeContainer, (List) arraylist); } else { @@ -1167,6 +1173,7 @@ + } + } + ++ event.setCancelled(cancelled); + server.getPluginManager().callEvent(event); + + switch (event.getResult()) { @@ -1235,7 +1242,7 @@ if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); -@@ -772,8 +1641,50 @@ +@@ -772,8 +1643,50 @@ } boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize(); @@ -1287,7 +1294,7 @@ if (flag1 && flag2 && flag3) { if (itemstack == null) { -@@ -796,6 +1707,7 @@ +@@ -796,6 +1709,7 @@ } public void a(PacketPlayInTransaction packetplayintransaction) { @@ -1295,7 +1302,7 @@ PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u()); Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); -@@ -806,6 +1718,7 @@ +@@ -806,6 +1720,7 @@ } public void a(PacketPlayInUpdateSign packetplayinupdatesign) { @@ -1303,7 +1310,7 @@ PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u()); this.player.z(); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); -@@ -822,10 +1735,24 @@ +@@ -822,10 +1737,24 @@ if (!tileentitysign.b() || tileentitysign.c() != this.player) { this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); @@ -1329,7 +1336,7 @@ tileentitysign.update(); worldserver.notify(blockposition); } -@@ -847,11 +1774,28 @@ +@@ -847,11 +1776,28 @@ public void a(PacketPlayInAbilities packetplayinabilities) { PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u()); @@ -1359,7 +1366,7 @@ ArrayList arraylist = Lists.newArrayList(); Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator(); -@@ -891,13 +1835,15 @@ +@@ -891,13 +1837,15 @@ itemstack1 = this.player.inventory.getItemInHand(); if (itemstack1 != null) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { @@ -1376,7 +1383,7 @@ return; } finally { packetdataserializer.release(); -@@ -909,27 +1855,31 @@ +@@ -909,27 +1857,31 @@ try { itemstack = packetdataserializer.i(); @@ -1420,7 +1427,7 @@ return; } finally { packetdataserializer.release(); -@@ -946,11 +1896,12 @@ +@@ -946,11 +1898,12 @@ } } catch (Exception exception2) { PlayerConnection.c.error("Couldn\'t select trade", exception2); @@ -1434,7 +1441,7 @@ packetdataserializer = packetplayincustompayload.b(); try { -@@ -986,6 +1937,7 @@ +@@ -986,6 +1939,7 @@ } } catch (Exception exception3) { PlayerConnection.c.error("Couldn\'t set command block", exception3); @@ -1442,7 +1449,7 @@ } finally { packetdataserializer.release(); } -@@ -1011,6 +1963,7 @@ +@@ -1011,6 +1965,7 @@ } } catch (Exception exception4) { PlayerConnection.c.error("Couldn\'t set beacon", exception4); @@ -1450,7 +1457,7 @@ } } } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) { -@@ -1026,6 +1979,27 @@ +@@ -1026,6 +1981,27 @@ containeranvil.a(""); } } -- cgit v1.2.3