Java 类net.minecraft.server.PacketPlayInCloseWindow 实例源码

项目:CraftBukkit    文件:CraftEventFactory.java   
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;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
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;
}