Java 类org.bukkit.event.inventory.InventoryOpenEvent 实例源码

项目:BedwarsXP    文件:NewEventListeners.java   
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
    if (e.getPlayer().equals(null)) {
        return;
    }
    if (e.getInventory().equals(null)) {
        return;
    }
    Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
            .getGameManager().getGameOfPlayer((Player) e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
        e.setCancelled(true);
    }
}
项目:BedwarsXP    文件:OldEventListeners.java   
@EventHandler
public void onAnvilOpen(InventoryOpenEvent e) {
    if (e.getPlayer().equals(null)) {
        return;
    }
    if (e.getInventory().equals(null)) {
        return;
    }
    Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
            .getGameOfPlayer((Player) e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    if (e.getInventory().getType().equals(InventoryType.ANVIL)) {
        e.setCancelled(true);
    }
}
项目:RPGInventory    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
    Inventory inventory = event.getInventory();
    HumanEntity player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    if (InventoryAPI.isRPGInventory(inventory)) {
        PlayerWrapper playerWrapper = (PlayerWrapper) inventory.getHolder();
        InventoryManager.syncQuickSlots(playerWrapper);
        InventoryManager.syncInfoSlots(playerWrapper);
        InventoryManager.syncShieldSlot(playerWrapper);
        InventoryManager.syncArmor(playerWrapper);
    }
}
项目:RPGInventory    文件:PetListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onPetInventoryOpened(InventoryOpenEvent event) {
    Player player = (Player) event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    final PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && event.getInventory().getHolder() == playerWrapper.getPet()) {
        playerWrapper.openInventory();
        event.setCancelled(true);

        new BukkitRunnable() {
            @Override
            public void run() {
                HorseInventory horseInv = ((Horse) playerWrapper.getPet()).getInventory();
                horseInv.setSaddle(new ItemStack(Material.SADDLE));
            }
        }.runTaskLater(RPGInventory.getInstance(), 1);
    }
}
项目:MazePlugin    文件:MazePlugin.java   
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e)
{
    if(maze != null)
    {
    //System.out.println("OpneInv");
        if(maze.checkIfInMaze(e.getPlayer().getLocation()))
        {
            HashMap<String,Object> status = (HashMap<String, Object>) Anti_hanging.get(e.getPlayer().getUniqueId().toString());
            status.put("interrupted",true);
        }
    }
}
项目:factions-top    文件:WorthListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void checkWorth(InventoryOpenEvent event) {
    // Do nothing if a player did not open the inventory or if chest events
    // are disabled.
    if (!(event.getPlayer() instanceof Player) || plugin.getSettings().isDisableChestEvents()) {
        return;
    }

    Inventory inventory = event.getInventory();

    // Set all default worth values for this chest.
    if (inventory.getHolder() instanceof DoubleChest) {
        DoubleChest chest = (DoubleChest) inventory.getHolder();
        checkWorth((Chest) chest.getLeftSide());
        checkWorth((Chest) chest.getRightSide());
    }

    if (inventory.getHolder() instanceof Chest) {
        checkWorth((Chest) inventory.getHolder());
    }
}
项目: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;
}
项目:Craftbukkit    文件:CraftEventFactory.java   
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));
    }

    CraftServer server = player.world.getServer();
    CraftPlayer craftPlayer = player.getBukkitEntity();
    player.activeContainer.transferTo(container, craftPlayer);

    InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
    event.setCancelled(cancelled);
    server.getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        container.transferTo(player.activeContainer, craftPlayer);
        return null;
    }

    return container;
}
项目:uSkyBlock    文件:ExploitEvents.java   
@EventHandler
public void onVillagerTrade(InventoryOpenEvent event) {
    if (!plugin.isSkyAssociatedWorld(event.getPlayer().getWorld())) {
        return;
    }
    if (!(event.getPlayer() instanceof Player)) {
        return;
    }
    if (villagerTradingEnabled
            && event.getPlayer() instanceof Player
            && !(hasPermission(event.getPlayer(), "usb.mod.bypassprotection"))
            && event.getInventory().getType() == InventoryType.MERCHANT
            && !plugin.playerIsOnIsland((Player)event.getPlayer())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(tr("\u00a7eTrading isn't allowed on other islands. Do it in spawn."));
        return;
    }
}
项目:civcraft    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
    if (event.getInventory() instanceof DoubleChestInventory) {
        DoubleChestInventory doubleInv = (DoubleChestInventory)event.getInventory();

        Chest leftChest = (Chest)doubleInv.getHolder().getLeftSide();           
        /*Generate a new player 'switch' event for the left and right chests. */
        PlayerInteractEvent interactLeft = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, leftChest.getBlock(), null);
        BlockListener.OnPlayerSwitchEvent(interactLeft);

        if (interactLeft.isCancelled()) {
            event.setCancelled(true);
            return;
        }

        Chest rightChest = (Chest)doubleInv.getHolder().getRightSide();
        PlayerInteractEvent interactRight = new PlayerInteractEvent((Player)event.getPlayer(), Action.RIGHT_CLICK_BLOCK, null, rightChest.getBlock(), null);
        BlockListener.OnPlayerSwitchEvent(interactRight);

        if (interactRight.isCancelled()) {
            event.setCancelled(true);
            return;
        }           
    }
}
项目:Almura-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.handleContainerClose(new Packet101CloseWindow(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;
}
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
    Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());

    if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
        return;
    }

    HumanEntity player = event.getPlayer();

    if (!UserManager.hasPlayerDataKey(player)) {
        return;
    }

    furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
}
项目:modules-extra    文件:ListenerContainerItem.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event)
{
    if (event.getPlayer() instanceof Player)
    {
        if (this.isActive(ItemInsert.class, event.getPlayer().getWorld())
         || this.isActive(ItemRemove.class, event.getPlayer().getWorld()))
        {
            /* TODO
            ContainerType type = new ContainerType(event.getInventory().getHolder());
            if (!config.container.CONTAINER_ignore.contains(type))
             */
            this.inventoryChanges.put(event.getPlayer().getUniqueId(), new HashMap<ItemData, Integer>());
        }
    }
}
项目:CrazyLogin    文件:DynamicPlayerListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void PlayerInventoryOpen(final InventoryOpenEvent event)
{
    if (!(event.getPlayer() instanceof Player))
        return;
    final Player player = (Player) event.getPlayer();
    if (plugin.isLoggedIn(player))
    {
        final LoginPlayerData playerdata = plugin.getPlayerData(player);
        if (playerdata != null)
            playerdata.notifyAction();
        return;
    }
    event.setCancelled(true);
    player.closeInventory();
    plugin.sendAuthReminderMessage(player);
}
项目:SpigotSource    文件:CraftEventFactory.java   
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));
    }

    CraftServer server = player.world.getServer();
    CraftPlayer craftPlayer = player.getBukkitEntity();
    player.activeContainer.transferTo(container, craftPlayer);

    InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
    event.setCancelled(cancelled);
    server.getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        container.transferTo(player.activeContainer, craftPlayer);
        return null;
    }

    return container;
}
项目:GoldRushPlugin    文件:TrainStationLis.java   
/**
 * Controls chest ownership for carts.
 *
 * @param e The {@link InventoryMoveItemEvent} associated with the chest.
 */
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
    Inventory inv = e.getInventory();
    if (e.getPlayer() instanceof Player) {
        Player p = (Player) e.getPlayer();
        if (inv.getHolder() instanceof Minecart) {
            Minecart cart = (Minecart) inv.getHolder();
            MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
            if (toCheck != null && !toCheck.isDerailed()) {
                CartProperties cp = toCheck.getProperties();
                if (!cp.getOwners().contains(p.getName().toLowerCase())) {
                    p.sendMessage(ChatColor.RED + "You do not own this chest!");
                    e.setCancelled(true);
                }
            }
        }
    }
}
项目:NPlugins    文件:ItemNetworkListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(final InventoryOpenEvent event) {
    final Inventory inventory = event.getInventory();
    final InventoryHolder holder = inventory.getHolder();
    if (holder instanceof Chest || holder instanceof DoubleChest) {
        final BlockState chest = (BlockState)(holder instanceof Chest ? holder : ((DoubleChest)holder).getLeftSide());
        final Block block = chest.getBlock();
        final NLocation loc = new NLocation(block.getLocation());
        final List<Sign> signs = SignUtil.getSignsForChest(block);
        for (final Sign sign : signs) {
            if (sign.getLine(0).equals(ITEMNETWORK_EMITTER)) {
                this.feature.lock(loc);
            }
        }
    }
}
项目:HopperFilterSimplified    文件:HfsBlockListener.java   
/**
 * Event handler to watch whenever a chest is opened.
 * This will prevent the opening of the chest if necessary.
 *  
 * @param event inventoryOpenEvent representing the inventory object that was just opened. We care about a Chest inventory being opened
 */
@EventHandler (ignoreCancelled=true)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
    //get the destination inventory
    InventoryHolder holder = event.getInventory().getHolder();
    //Make sure it is a chest
    if (holder instanceof Chest) {
        Location chestLocation = ((Chest) holder).getLocation();
        //see if a filter is around the location
        if (plugin.isChestNextToHopper(chestLocation)) {
            Player player = (Player) event.getPlayer();
            if (!player.hasPermission("hopperfiltersimplified.build.alter.chest")) {
                plugin.sendMessageInfo(player, "You do not have rights to alter this hopper filter chest.");
                event.setCancelled(true);
            }

            //debug if requested
            if (plugin.debugLevel_get() > 0) plugin.getLogger().info("Chest next to hopper opened at (" + chestLocation.toString() + ")");
        }            
    }
}
项目:RPG-Items    文件:Events.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(final InventoryOpenEvent e) {
    if (e.getView() instanceof LocaleInventory)
        return;
    if (e.getInventory().getType() != InventoryType.CHEST || !useLocaleInv) {
        Inventory in = e.getInventory();
        Iterator<ItemStack> it = in.iterator();
        String locale = Locale.getPlayerLocale((Player) e.getPlayer());
        try {
            while (it.hasNext()) {
                ItemStack item = it.next();
                if (ItemManager.toRPGItem(item) != null)
                    RPGItem.updateItem(item, locale);
            }
        } catch (ArrayIndexOutOfBoundsException ex) {
            // Fix for the bug with anvils in craftbukkit
        }
    } else if (useLocaleInv) {
        LocaleInventory localeInv = new LocaleInventory((Player) e.getPlayer(), e.getView());
        e.setCancelled(true);
        e.getPlayer().openInventory(localeInv);
        localeInventories.add(localeInv);
    }
}
项目:ECHorses    文件:ECHorsesListeners.java   
@EventHandler
public void protectHorseInventory(InventoryOpenEvent event){
    if(event.getInventory().getHolder() instanceof Horse){
        Horse h = (Horse)event.getInventory().getHolder();
        Player p = (Player) event.getPlayer();
        String playername = event.getPlayer().getName();
        if(p.isOp() || p.hasPermission("echorse.override")){ //Op & permission check
            return;
        }
        if(!(h.getOwner().getName() == playername)){ //Not the horse owner, cancel event

            event.setCancelled(true);
            p.sendMessage(ChatColor.AQUA + "[ECHorses]" + ChatColor.RED + " You dont have permission to open " + h.getOwner().getName() + "'s horse inventory!");
            return;
        }
        return;
    }
    return; 
}
项目:AuthMeReloaded    文件:PlayerListenerTest.java   
@Test
public void shouldAllowInventoryOpen() {
    // given
    HumanEntity player = mock(Player.class);
    InventoryView transaction = mock(InventoryView.class);
    given(transaction.getPlayer()).willReturn(player);
    InventoryOpenEvent event = new InventoryOpenEvent(transaction);
    given(event.getPlayer()).willReturn(player);
    given(listenerService.shouldCancelEvent(player)).willReturn(false);

    // when
    listener.onPlayerInventoryOpen(event);

    // then
    assertThat(event.isCancelled(), equalTo(false));
    verifyZeroInteractions(bukkitService);
}
项目:AuthMeReloaded    文件:PlayerListenerTest.java   
@Test
public void shouldCancelInventoryOpen() {
    // given
    HumanEntity player = mock(Player.class);
    InventoryView transaction = mock(InventoryView.class);
    given(transaction.getPlayer()).willReturn(player);
    InventoryOpenEvent event = new InventoryOpenEvent(transaction);
    given(event.getPlayer()).willReturn(player);
    given(listenerService.shouldCancelEvent(player)).willReturn(true);
    setBukkitServiceToScheduleSyncDelayedTaskWithDelay(bukkitService);

    // when
    listener.onPlayerInventoryOpen(event);

    // then
    assertThat(event.isCancelled(), equalTo(true));
    verify(player).closeInventory();
}
项目:Craft-city    文件:CraftEventFactory.java   
public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
    if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
        player.playerConnection.handleContainerClose(new Packet101CloseWindow(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;
}
项目:RPG-Items-2    文件:Events.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onInventoryOpen(final InventoryOpenEvent e) {
    if (e.getView() instanceof LocaleInventory)
        return;
    if (e.getInventory().getType() != InventoryType.CHEST || !useLocaleInv) {
        Inventory in = e.getInventory();
        Iterator<ItemStack> it = in.iterator();
        String locale = Locale.getPlayerLocale((Player) e.getPlayer());
        try {
            while (it.hasNext()) {
                ItemStack item = it.next();
                if (ItemManager.toRPGItem(item) != null)
                    RPGItem.updateItem(item, locale);
            }
        } catch (ArrayIndexOutOfBoundsException ex) {
            // Fix for the bug with anvils in craftbukkit
        }
    } else if (useLocaleInv) {
        LocaleInventory localeInv = new LocaleInventory((Player) e.getPlayer(), e.getView());
        e.setCancelled(true);
        e.getPlayer().openInventory(localeInv);
        localeInventories.add(localeInv);
    }
}
项目:MCPBukkit    文件:CraftEventFactory.java   
public static net.minecraft.inventory.Container callInventoryOpenEvent(net.minecraft.entity.player.EntityPlayerMP player, net.minecraft.inventory.Container container) {
    if (player.field_71070_bA != player.field_71069_bz) { // fire INVENTORY_CLOSE if one already open
        player.field_71135_a.func_72474_a(new net.minecraft.network.packet.Packet101CloseWindow(player.field_71070_bA.field_75152_c));
    }

    CraftServer server = ((net.minecraft.world.WorldServer) player.field_70170_p).getServer();
    CraftPlayer craftPlayer = (CraftPlayer) player.getBukkitEntity();
    player.field_71070_bA.transferTo(container, craftPlayer);

    InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
    server.getPluginManager().callEvent(event);

    if (event.isCancelled()) {
        container.transferTo(player.field_71070_bA, craftPlayer);
        return null;
    }

    return container;
}
项目:GoldRushMC    文件:TrainStationLis.java   
/**
 * This will facilitate the need to update the {@link TrainFactory#ownerStorage} list, because if the inventory changes, the instance changes.
 * 
 * @param e The {@link InventoryMoveItemEvent} associated with the chest.
 */
@EventHandler
public void onInventoryOpening(InventoryOpenEvent e) {
    Inventory inv = e.getInventory();
    if(e.getPlayer() instanceof Player) {
        Player p = (Player) e.getPlayer();
        if(inv.getHolder() instanceof Minecart) {
            Minecart cart = (Minecart) inv.getHolder();
            MinecartMember<?> toCheck = MinecartMemberStore.getAt(cart.getLocation());
            if(toCheck != null) {
                CartProperties cp = toCheck.getProperties();
                if(!cp.getOwners().contains(p.getName().toLowerCase())) {
                    p.sendMessage(ChatColor.RED + "You do not own this chest!");
                    e.setCancelled(true);
                }
            }
        }
    }
}
项目:GoldRushMC    文件:TrainLis.java   
/**
 * This will be used to facilitate the permissions of chest minecarts.
 * 
 * @param event The {@link InventoryOpenEvent} associated with the chest.
 */
public void onChestClick(InventoryOpenEvent event) {

    event.setCancelled(true);

    Player p = (Player) event.getPlayer();
    Inventory i = event.getInventory();

    if(TrainFactory.ownerStorage.containsKey(p)) {
        for(MinecartMemberChest chest : TrainFactory.getInventoryList(p)) {
            if(chest.getEntity().getInventory() == i) {
                event.setCancelled(false);
                break;
            }
        }
    }
}
项目:Uranium    文件:CraftEventFactory.java   
public static net.minecraft.inventory.Container callInventoryOpenEvent(net.minecraft.entity.player.EntityPlayerMP player, net.minecraft.inventory.Container container, boolean closeInv) {
    if (player.openContainer != player.inventoryContainer && closeInv) { // fire INVENTORY_CLOSE if one already open
// Cauldron end
        player.playerNetServerHandler.processCloseWindow(new net.minecraft.network.play.client.C0DPacketCloseWindow(player.openContainer.windowId));
    }

    CraftServer server = player.worldObj.getServer();
    CraftPlayer craftPlayer = player.getBukkitEntity();
    // Cauldron start - vanilla compatibility
    try {
        player.openContainer.transferTo(container, craftPlayer);
    }
    catch (AbstractMethodError e) {
        // do nothing
    }
    // Cauldron end
    InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
    if (container.getBukkitView() != null) server.getPluginManager().callEvent(event); // Cauldron - allow vanilla mods to bypass

    if (event.isCancelled()) {
        container.transferTo(player.openContainer, craftPlayer);
        // Cauldron start - handle close for modded containers
        if (!closeInv) { // fire INVENTORY_CLOSE if one already open
            player.openContainer = container; // make sure the right container is processed
            player.closeScreen();
            player.openContainer = player.inventoryContainer;
        }
        // Cauldron end
        return null;
    }

    return container;
}
项目:PetBlocks    文件:PetBlockListener.java   
@EventHandler
public void onInventoryOpenEvent(InventoryOpenEvent event) {
    final Player player = (Player) event.getPlayer();
    if (this.manager.carryingPet.contains(player)) {
        event.setCancelled(true);
        event.getPlayer().closeInventory();
    }
}
项目:SparseBukkitAPI    文件:MenuManager.java   
@EventHandler
public void onInventoryOpen(InventoryOpenEvent e)
{
    if(!(e.getPlayer() instanceof Player))
        return;

    Inventory inv = e.getInventory();
    InventoryHolder holder = inv.getHolder();
    if(holder != null && holder instanceof Menu)
    {
        Menu menu = (Menu) holder;
        menu.viewers.add((Player) e.getPlayer());
        openMenus.add(menu);
    }
}
项目:ProjectAres    文件:FillListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
    final MatchPlayer opener = playerFinder.getParticipant(event.getActor());
    if(opener == null) return;

    final Inventory inventory = event.getInventory();
    final Predicate<Filter> passesFilter = passesFilter(inventory.getHolder());
    if(passesFilter == null) return;

    logger.fine(() -> opener.getName() + " opened a " + inventory.getHolder().getClass().getSimpleName());

    // Find all Fillers that apply to the holder of the opened inventory
    final List<Filler> fillers = this.fillers.stream()
                                             .filter(filler -> passesFilter.test(filler.filter()))
                                             .collect(Collectors.toImmutableList());
    if(fillers.isEmpty()) return;

    logger.fine(() -> "Found fillers " + fillers.stream()
                                                .map(Filler::identify)
                                                .collect(java.util.stream.Collectors.joining(", ")));

    // Find all Caches that the opened inventory is part of
    final List<Fillable> fillables = new ArrayList<>();
    for(Cache cache : caches) {
        if(passesFilter.test(cache.region()) && passesFilter.test(cache.filter())) {
            fillables.add(new FillableCache(cache));
        }
    }
    // If the inventory is not in any Cache, just fill it directly
    if(fillables.isEmpty()) {
        fillables.add(new FillableInventory(inventory));
    }

    fillables.forEach(fillable -> fillable.fill(opener, fillers));
}
项目:SmartInvs    文件:InventoryManager.java   
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent e) {
    Player p = (Player) e.getPlayer();

    if(!inventories.containsKey(p))
        return;

    SmartInventory inv = inventories.get(p);

    inv.getListeners().stream()
            .filter(listener -> listener.getType() == InventoryOpenEvent.class)
            .forEach(listener -> ((InventoryListener<InventoryOpenEvent>) listener).accept(e));
}
项目:AlphaLibary    文件:MinigameLogic.java   
@EventHandler
public void onBlockInvOpen(InventoryOpenEvent e) {
    if (GameStatus.isState(gameStatus))
        if (e.getInventory().getType() != InventoryType.PLAYER
                || e.getInventory().getType() != InventoryType.CHEST)
            e.setCancelled(!canOpenBlockInv);
}
项目:SurvivalAPI    文件:AutomaticLapisModule.java   
/**
 * Fill the lapis lazuli slot
 *
 * @param event Event
 */
@EventHandler
public void onInventoryOpen(InventoryOpenEvent event)
{
    if (event.getInventory().getType() == InventoryType.ENCHANTING)
        event.getInventory().setItem(1, new ItemStack(Material.INK_SACK, 64, (short) 4));
}
项目:RPGInventory    文件:CraftListener.java   
@EventHandler(priority = EventPriority.LOW)
public void onInventoryOpen(InventoryOpenEvent event) {
    final Player player = (Player) event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)
            || event.getInventory().getType() != InventoryType.WORKBENCH
            || isNotNeededHere(player)) {
        return;
    }

    //noinspection deprecation
    player.updateInventory();
}
项目:HCFCore    文件:SubclaimWandListener.java   
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onInventoryOpen(InventoryOpenEvent event) {
    HumanEntity humanEntity = event.getPlayer();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        if (player.getInventory().contains(ClaimHandler.SUBCLAIM_WAND)) {
            player.getInventory().remove(ClaimHandler.SUBCLAIM_WAND);
            plugin.getClaimHandler().clearClaimSelection(player);
        }
    }
}
项目:HCFCore    文件:ClaimWandListener.java   
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onInventoryOpen(InventoryOpenEvent event) {
    HumanEntity humanEntity = event.getPlayer();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        if (player.getInventory().contains(ClaimHandler.CLAIM_WAND)) {
            player.getInventory().remove(ClaimHandler.CLAIM_WAND);
            plugin.getClaimHandler().clearClaimSelection(player);
        }
    }
}
项目:HCFCore    文件:SubclaimWandListener.java   
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onInventoryOpen(InventoryOpenEvent event) {
    HumanEntity humanEntity = event.getPlayer();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        if (player.getInventory().contains(ClaimHandler.SUBCLAIM_WAND)) {
            player.getInventory().remove(ClaimHandler.SUBCLAIM_WAND);
            plugin.getClaimHandler().clearClaimSelection(player);
        }
    }
}
项目:HCFCore    文件:ClaimWandListener.java   
@EventHandler(ignoreCancelled = false, priority = EventPriority.NORMAL)
public void onInventoryOpen(InventoryOpenEvent event) {
    HumanEntity humanEntity = event.getPlayer();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        if (player.getInventory().contains(ClaimHandler.CLAIM_WAND)) {
            player.getInventory().remove(ClaimHandler.CLAIM_WAND);
            plugin.getClaimHandler().clearClaimSelection(player);
        }
    }
}