SPIGOT-287: Fire a cancelled inventory open event for locked chests

By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
CraftBukkit/Spigot
2014-12-28 15:14:53 +00:00
parent d6d6e260d7
commit 54a4d6d1b4
2 changed files with 45 additions and 24 deletions

View File

@@ -680,6 +680,10 @@ public class CraftEventFactory {
}
public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
return callInventoryOpenEvent(player, container, false);
}
public static Container callInventoryOpenEvent(EntityPlayer player, Container container, boolean cancelled) {
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId));
}
@@ -689,6 +693,7 @@ public class CraftEventFactory {
player.activeContainer.transferTo(container, craftPlayer);
InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
event.setCancelled(cancelled);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {