SPIGOT-270: Fire inventory events for spectator mode (but cancelled)

This commit is contained in:
Thinkofdeath 2015-01-04 20:23:54 +00:00
parent c4fd085432
commit d4eaf226f9

View File

@ -1,5 +1,5 @@
--- ../work/decompile-8eb82bde//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:11:55.473664041 +0000 +++ src/main/java/net/minecraft/server/PlayerConnection.java 2015-01-04 20:23:44.413656346 +0000
@@ -16,6 +16,48 @@ @@ -16,6 +16,48 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -946,7 +946,7 @@
} else if (this.player.u().getWorldData().isHardcore()) { } else if (this.player.u().getWorldData().isHardcore()) {
if (this.minecraftServer.S() && this.player.getName().equals(this.minecraftServer.R())) { 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!"); 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) { public void a(PacketPlayInCloseWindow packetplayinclosewindow) {
@ -964,7 +964,13 @@
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.u());
this.player.z(); this.player.z();
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) { 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); this.player.a(this.player.activeContainer, (List) arraylist);
} else { } else {
@ -1167,6 +1173,7 @@
+ } + }
+ } + }
+ +
+ event.setCancelled(cancelled);
+ server.getPluginManager().callEvent(event); + server.getPluginManager().callEvent(event);
+ +
+ switch (event.getResult()) { + switch (event.getResult()) {
@ -1235,7 +1242,7 @@
if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) { if (ItemStack.matches(packetplayinwindowclick.e(), itemstack)) {
this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.a(), packetplayinwindowclick.d(), true)); 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(); boolean flag1 = packetplayinsetcreativeslot.a() >= 1 && packetplayinsetcreativeslot.a() < 36 + PlayerInventory.getHotbarSize();
@ -1287,7 +1294,7 @@
if (flag1 && flag2 && flag3) { if (flag1 && flag2 && flag3) {
if (itemstack == null) { if (itemstack == null) {
@@ -796,6 +1707,7 @@ @@ -796,6 +1709,7 @@
} }
public void a(PacketPlayInTransaction packetplayintransaction) { public void a(PacketPlayInTransaction packetplayintransaction) {
@ -1295,7 +1302,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.u());
Short oshort = (Short) this.n.get(this.player.activeContainer.windowId); Short oshort = (Short) this.n.get(this.player.activeContainer.windowId);
@@ -806,6 +1718,7 @@ @@ -806,6 +1720,7 @@
} }
public void a(PacketPlayInUpdateSign packetplayinupdatesign) { public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
@ -1303,7 +1310,7 @@
PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinupdatesign, this, this.player.u());
this.player.z(); this.player.z();
WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
@@ -822,10 +1735,24 @@ @@ -822,10 +1737,24 @@
if (!tileentitysign.b() || tileentitysign.c() != this.player) { if (!tileentitysign.b() || tileentitysign.c() != this.player) {
this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign"); this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
@ -1329,7 +1336,7 @@
tileentitysign.update(); tileentitysign.update();
worldserver.notify(blockposition); worldserver.notify(blockposition);
} }
@@ -847,11 +1774,28 @@ @@ -847,11 +1776,28 @@
public void a(PacketPlayInAbilities packetplayinabilities) { public void a(PacketPlayInAbilities packetplayinabilities) {
PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u()); PlayerConnectionUtils.ensureMainThread(packetplayinabilities, this, this.player.u());
@ -1359,7 +1366,7 @@
ArrayList arraylist = Lists.newArrayList(); ArrayList arraylist = Lists.newArrayList();
Iterator iterator = this.minecraftServer.tabCompleteCommand(this.player, packetplayintabcomplete.a(), packetplayintabcomplete.b()).iterator(); 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(); itemstack1 = this.player.inventory.getItemInHand();
if (itemstack1 != null) { if (itemstack1 != null) {
if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) { if (itemstack.getItem() == Items.WRITABLE_BOOK && itemstack.getItem() == itemstack1.getItem()) {
@ -1376,7 +1383,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -909,27 +1855,31 @@ @@ -909,27 +1857,31 @@
try { try {
itemstack = packetdataserializer.i(); itemstack = packetdataserializer.i();
@ -1420,7 +1427,7 @@
return; return;
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
@@ -946,11 +1896,12 @@ @@ -946,11 +1898,12 @@
} }
} catch (Exception exception2) { } catch (Exception exception2) {
PlayerConnection.c.error("Couldn\'t select trade", exception2); PlayerConnection.c.error("Couldn\'t select trade", exception2);
@ -1434,7 +1441,7 @@
packetdataserializer = packetplayincustompayload.b(); packetdataserializer = packetplayincustompayload.b();
try { try {
@@ -986,6 +1937,7 @@ @@ -986,6 +1939,7 @@
} }
} catch (Exception exception3) { } catch (Exception exception3) {
PlayerConnection.c.error("Couldn\'t set command block", exception3); PlayerConnection.c.error("Couldn\'t set command block", exception3);
@ -1442,7 +1449,7 @@
} finally { } finally {
packetdataserializer.release(); packetdataserializer.release();
} }
@@ -1011,6 +1963,7 @@ @@ -1011,6 +1965,7 @@
} }
} catch (Exception exception4) { } catch (Exception exception4) {
PlayerConnection.c.error("Couldn\'t set beacon", 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) { } else if ("MC|ItemName".equals(packetplayincustompayload.a()) && this.player.activeContainer instanceof ContainerAnvil) {
@@ -1026,6 +1979,27 @@ @@ -1026,6 +1981,27 @@
containeranvil.a(""); containeranvil.a("");
} }
} }