public static Container callInventoryOpenEvent(EntityPlayer player, Container container) { if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId)); } CraftServer server = player.world.getServer(); CraftPlayer craftPlayer = player.getBukkitEntity(); player.activeContainer.transferTo(container, craftPlayer); InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView()); server.getPluginManager().callEvent(event); if (event.isCancelled()) { container.transferTo(player.activeContainer, craftPlayer); return null; } return container; }