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

项目:UltraCore    文件:Events.java   
@EventHandler
public void onInventoryClick2(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Here Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {   
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport " + ChatColor.GREEN + targetPlayer.getName() + ChatColor.YELLOW + " to you."))) {
                    player.closeInventory();
                    targetPlayer.teleport(player);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + " to you!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);  
                }
               }
           }
       }
   }
项目:UltraCore    文件:Events.java   
@EventHandler
public void onInventoryClick1(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack is = event.getCurrentItem();
    if ((event.getCurrentItem() != null) && (event.getCurrentItem().getType() != Material.AIR)) {
        if (event.getInventory().getName().equals(ChatColor.DARK_GRAY + "Teleport Menu - Page 1")) {
            event.setCancelled(true);
            for (int i = 0; i < Bukkit.getOnlinePlayers().size(); i++) {
                Player targetPlayer = (Player) Bukkit.getOnlinePlayers().toArray()[i];
                Location location = player.getLocation();
                if ((event.getCurrentItem().getType() == Material.SKULL_ITEM) && (is.hasItemMeta()) && (is.getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Teleport to " + ChatColor.GREEN + targetPlayer.getName()))) {
                    player.closeInventory();
                    player.teleport(targetPlayer);
                    player.sendMessage(ChatColor.YELLOW + "You've teleported to " + ChatColor.GREEN + targetPlayer.getDisplayName() + ChatColor.YELLOW + "!");
                    player.playSound(location, Sound.ENTITY_ENDERMEN_TELEPORT, 100, 1);
                    player.playEffect(location, Effect.ENDER_SIGNAL, 1);
                    targetPlayer.playEffect(location, Effect.ENDER_SIGNAL, 1);
                }
            }
        }
    }
}
项目:MCLibrary    文件:PageGUI.java   
@Override
protected void onClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    int rawSlot = event.getRawSlot();
    boolean isFrame = isFrame(rawSlot);
    if (isFrame) {
        event.setCancelled(true);
    }
    if (rawSlot == prevPageBtnIndex) {
        prevPage(player);
    } else if (rawSlot == nextPageBtnIndex) {
        nextPage(player);
    } else if (!isFrame) {
        InventoryClickEvent converted = convert(event);
        getHandlers().notify(converted);
        event.setCancelled(converted.isCancelled());
        return;
    }
    open(event.getWhoClicked());
}
项目:SurvivalAPI    文件:SurvivalTeamSelector.java   
/**
 * Event fired when a player clicks in the team selection GUI
 *
 * @param event Event
 */
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
    if (this.game.getStatus().equals(Status.IN_GAME))
    {
        event.getHandlers().unregister(this);
    }
    else if (event.getCurrentItem() != null && event.getCurrentItem().getItemMeta() != null && event.getView().getType() != InventoryType.PLAYER)
    {
        AbstractGui gui = this.playersGui.get(event.getWhoClicked().getUniqueId());

        if (gui != null)
        {
            String action = gui.getAction(event.getSlot());

            if (action != null)
                gui.onClick((Player) event.getWhoClicked(), event.getCurrentItem(), action, event.getClick());

            event.setCancelled(true);
        }
    }
}
项目:ZorahPractice    文件:PlayerListener.java   
@EventHandler
public void onInventoryMove(InventoryClickEvent event) {
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }

    Player player = (Player) event.getWhoClicked();
    PracticeProfile profile = ManagerHandler.getPlayerManager().getPlayerProfile(player);

    if (profile.getStatus() == PlayerStatus.EDITING_KITS || profile.getStatus() == PlayerStatus.PLAYING) {
        return;
    }

    if ((player.hasPermission("practice.admin") || player.isOp()) && player.getGameMode() == GameMode.CREATIVE) {
        return;
    }

    event.setCancelled(true);
}
项目:MCLibrary    文件:GUI.java   
@EventHandler
public void onClick(InventoryClickEvent e) {
    guiMap.getOptional(e.getWhoClicked()).ifPresent(gui -> {
        InventoryAction action = e.getAction();
        Inventory inv = e.getInventory();

        if (action == InventoryAction.COLLECT_TO_CURSOR) {
            for (ItemStack item : inv) {
                if (e.getCursor().isSimilar(item)) {
                    e.setCancelled(true);
                    break;
                }
            }
        }

        gui.getHandlers().notify(e);
    });
}
项目:Crescent    文件:InventoryTweaksB.java   
@Override
public void call(Event event) {
    if (event instanceof InventoryClickEvent) {
        final InventoryClickEvent ice = (InventoryClickEvent) event;

        if (ice.getCurrentItem().getType() == Material.BOWL) {

            final int slot = ice.getSlot();

            if (!slotsChosen.containsKey(slot)) {
                slotsChosen.put(slot, 1);
            } else {
                slotsChosen.put(slot, slotsChosen.get(slot) + 1);
            }

            if (getStackChance() >= 100.0) {
                callback(true);
            }
        }
    }
}
项目:uppercore    文件:GuiManager.java   
/**
 * Called when a player clicks on the inventory, the filters to check if the Player clicked on the GUi's inventory should be made outside of this method
 *
 * @param event the click event
 */
public void onClick(InventoryClickEvent event) {
    HumanEntity h = event.getWhoClicked();
    if (!(h instanceof Player))
        return;
    LinkedList<Gui> g = histories.get(h);
    if (g != null && !g.isEmpty()) {
        Gui gui = g.peek();
        GuiClickEvent e = new GuiClickEvent(event, (Player) h, gui);
        Bukkit.getPluginManager().callEvent(e);
        if (e.isCancelled())
            return;

        //Event cancelled BEFORE the method call to permit the un-cancelling
        event.setCancelled(true);
        gui.onClick(event);
        //Creative idiots could copy the links
        if (event.isShiftClick() && event.getWhoClicked().getGameMode() == GameMode.CREATIVE)
            ((Player) event.getWhoClicked()).updateInventory();
    }
}
项目:uppercore    文件:SimpleGui.java   
@Override
public void onClick(InventoryClickEvent event) {
    if (buffer == null)
        throw new IllegalStateException("Cannot click a non-existant inventory");
    int slot = event.getSlot();
    if (slot < 0)
        return;
    int footerStart = buffer.getSize() - footer.size() - 1;
    Icon clicked;
    if(slot > footerStart) {
        clicked = footer.get(slot - footerStart - 1);
    } else if(slot < buffer.getSize()) {
        clicked = icons.get(slot);
    } else return;

    if (clicked != null)
        clicked.getClick().run((Player) event.getWhoClicked());
}
项目:ServerCommons    文件:DankMenuListeners.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    DankMenu menu = DankMenu.getByPlayer(player);

    if (menu == null) {
        return;
    }

    event.setCancelled(true);

    if (event.getClickedInventory() != null && event.getClickedInventory().getTitle().equals(menu.getInventory().getTitle())) {
        menu.onClickItem(event.getCurrentItem(), event.isRightClick());

        if (menu.getPlayer() != null && menu.getInventory() != null) {
            menu.updateInventory();
        }
    }
}
项目:SurvivalAPI    文件:RiskyRetrievalModule.java   
/**
 * Disable putting items in inventory
 *
 * @param event Click event instance
 */
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{
    if (event.getClickedInventory() == null || !event.getClickedInventory().equals(this.inventory))
        return;

    switch (event.getAction())
    {
        case PICKUP_ALL:
        case PICKUP_HALF:
        case PICKUP_ONE:
        case PICKUP_SOME:
            event.setCancelled(false);
            break;

        default:
            event.setCancelled(true);
            break;
    }
}
项目:pine-commons    文件:InventoryListener.java   
/**
 * On a player click on an item call InventoryBase.
 *
 * @param e The bukkit event.
 */
private boolean click(InventoryClickEvent e) {
    for (InventoryBase inv : InventoryBase.getInventories()) {
        //Filter items
        if (!inv.getItems().containsKey(e.getSlot()) || !inv.getItems().containsValue(e.getCurrentItem()))
            continue;

        //Setup methods
        if (e.isLeftClick())
            inv.onLeftClick((Player) e.getWhoClicked(), e.getCurrentItem());
        else
            inv.onRightClick((Player) e.getWhoClicked(), e.getCurrentItem());

        return inv.isCancelled();
    }

    return false;
}
项目:HCFCore    文件:KitsCommand.java   
@EventHandler
public void onInteract(InventoryClickEvent e) {
    Player player = (Player) e.getWhoClicked();

    if(!ChatColor.stripColor(e.getClickedInventory().getTitle()).equalsIgnoreCase("HCRiots Donator Kits")) {
        return;
    }

    if(e.getInventory().getSize() != 45) {
        return;
    }

    if(e.getClick() != ClickType.LEFT) {
        return;
    }

    if(ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()).equalsIgnoreCase("Titanium Kit")) {
        this.giveTitaniumKit(player);
    }
}
项目:UltimateSpawn    文件:BasicFeatures.java   
@EventHandler
public void onMove(InventoryClickEvent e) {
    Player p = (Player) e.getWhoClicked();

    if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Disable")) {
        if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.World.All_World")) {
            if (WorldUtils.getWMoveItem().contains(p.getWorld().getName())) {
            if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Bypass")) {
                 if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.moveitem")) {
                     e.setCancelled(true);
                 }
             } else {
                 e.setCancelled(true);
             }
            }
        } else {
            if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Move.Bypass")) {
                if (!p.hasPermission("ultimatespawn.event.playeritem.bypass.moveitem")) {
                    e.setCancelled(true);
                }
            } else {
                e.setCancelled(true);
            }
        }
    }
}
项目:HCFCore    文件:EnderPearlTimer.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onInventoryClick(InventoryClickEvent event) {
    HumanEntity humanEntity = event.getWhoClicked();
    if (humanEntity instanceof Player) {
        Player player = (Player) humanEntity;
        PearlNameFaker pearlNameFaker = itemNameFakes.get(player.getUniqueId());
        if (pearlNameFaker == null)
            return;

        // Required to prevent ghost items.
        int heldSlot = player.getInventory().getHeldItemSlot();
        if (event.getSlot() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(player.getItemInHand()), heldSlot);
        } else if (event.getHotbarButton() == heldSlot) {
            pearlNameFaker.setFakeItem(CraftItemStack.asNMSCopy(event.getCurrentItem()), event.getSlot());
            new BukkitRunnable() {
                @Override
                public void run() {
                    player.updateInventory();
                }
            }.runTask(plugin);
        }
    }
}
项目:AsgardAscension    文件:AbilityListener.java   
@EventHandler
public void onRepair(InventoryClickEvent event) {
    if(event.isCancelled() || !(event.getWhoClicked() instanceof Player) || !(event.getInventory() instanceof AnvilInventory))
        return;

    InventoryView view = event.getView();
    int rawSlot = event.getRawSlot();

    if(rawSlot != view.convertSlot(rawSlot) || rawSlot != 2)
        return;

    ItemStack item = event.getInventory().getItem(0);
    if(!plugin.getAbilityManager().hasAbility(item) || !plugin.getAbilityManager().isTemporaryItem(item))
        return;

    Ability ability = plugin.getAbilityManager().getAbility(item);
    event.getInventory().setItem(0, plugin.getAbilityManager().removeItemLore(item, ability));
    event.setCancelled(true);
}
项目:RPGInventory    文件:CraftListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onInventoryClick(InventoryClickEvent event) {
    final Player player = (Player) event.getWhoClicked();
    //noinspection ConstantConditions
    if (!InventoryManager.playerIsLoaded(player)
            || event.getInventory().getType() != InventoryType.WORKBENCH
            || isNotNeededHere(player)) {
        return;
    }

    List<CraftExtension> extensions = CraftManager.getExtensions(player);
    for (CraftExtension extension : extensions) {
        for (int slot : extension.getSlots()) {
            if (slot == event.getRawSlot()) {
                event.setCancelled(true);
                PlayerUtils.updateInventory(player);
                return;
            }
        }
    }
}
项目:FactionsXL    文件:TradeOfferCommand.java   
@EventHandler
public void onClick(InventoryClickEvent event) {
    String title = event.getInventory().getTitle();
    if (title.equals(FMessage.TRADE_OFFER_CHOOSE_PARTNER.getMessage())) {
        onClickChoosePartner(event);
    } else if (title.equals(FMessage.TRADE_OFFER_CHOOSE_RESOURCE.getMessage())) {
        onClickChooseResource(event);
        return;
    } else if (title.equals(FMessage.TRADE_OFFER_CHOOSE_EXPORT.getMessage())) {
        onClickChooseExport(event);
    } else if (title.startsWith(ChatColor.GREEN.toString() + ChatColor.BOLD.toString() + FMessage.TRADE_OFFER_AMOUNT.getMessage())) {
        onClickChoosePriceAndAmount(event);
    } else {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
}
项目:EscapeLag    文件:AntiLongStringCrash.java   
@EventHandler
public void ClickCheckItem(InventoryClickEvent evt){
    if(ConfigPatch.AntiLongStringCrashenable == true){
        if(evt.getWhoClicked().getType() != EntityType.PLAYER){
            return;
        }
        Player player = (Player) evt.getWhoClicked();
        ItemStack item = evt.getCursor();
        if(item != null){
            if(item.hasItemMeta() && item.getItemMeta().getDisplayName() != null){
                if(item.getItemMeta().getDisplayName().length() >= 127){
                    evt.setCancelled(true);
                    evt.setCurrentItem(null);
                    AzureAPI.log(player, ConfigPatch.AntiLongStringCrashWarnMessage);
                }
            }
        }
    }
}
项目:FactionsXL    文件:TradeMenu.java   
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || !gui.getTitle().equals(inventory.getTitle()) || event.getSlot() >= 45) {
        return;
    }
    ItemStack button = inventory.getItem(event.getSlot());
    if (button == null || button.equals(DISABLED)) {
        return;
    }
    if (!faction.isPrivileged(event.getWhoClicked())) {
        return;
    }
    Resource resource = Resource.getByIcon(button);
    openResourceMenu(player, resource);
}
项目:bskyblock    文件:PanelListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked(); // The player that
    // clicked the item
    //UUID playerUUID = player.getUniqueId();
    Inventory inventory = event.getInventory(); // The inventory that was

    if (openPanels.containsKey(player.getUniqueId())) {
        if (inventory.getName().equals(openPanels.get(player.getUniqueId()).getInventory().getName())) {
            Panel panel = openPanels.get(player.getUniqueId());

            for (int slot : panel.getItems().keySet()) {
                if (slot == event.getRawSlot()) {
                    if(!panel.getItems().get(slot).getClickHandler().onClick(player, ClickType.LEFT)) {
                        event.setCancelled(true);
                    }
                }
            }
        }
    }
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Prevents visitors picking items from riding horses or other inventories
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onHorseInventoryClick(InventoryClickEvent event) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: horse and llama inventory click");
    if (event.getInventory().getHolder() == null) {
        return;
    }
    // World check
    if (!Util.inWorld(event.getWhoClicked())) {
        return;
    }
    if (event.getInventory().getHolder() instanceof Animals) {
        if (actionAllowed((Player)event.getWhoClicked(), event.getWhoClicked().getLocation(), SettingsFlag.MOUNT_INVENTORY)) {
            return;
        }
        // Elsewhere - not allowed
        Util.sendMessage(event.getWhoClicked(), plugin.getLocale(event.getWhoClicked().getUniqueId()).get("island.protected"));
        event.setCancelled(true);
    }
}
项目:HCFCore    文件:FactionManagerArgument.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    ItemStack clicked = event.getCurrentItem();
    Inventory inventory = event.getInventory();

    if (inventory.getName().equals("Faction Management")) {

        if (clicked.getType() == Material.SKULL_ITEM) {
            if (event.getClick() == ClickType.LEFT) {
                Bukkit.dispatchCommand(player, "f promote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.MIDDLE){
                Bukkit.dispatchCommand(player, "f leader " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
            if (event.getClick() == ClickType.RIGHT) {
                Bukkit.dispatchCommand(player, "f demote " + clicked.getItemMeta().getDisplayName());
                event.setCancelled(true);
            }
        }
    }
}
项目:SuperiorCraft    文件:Menu.java   
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e) {
    if (e.getInventory().getName().equals(inv.getName())) {
        onInventoryClick(e);
    }
    ListIterator<Button> badd = abuttons.listIterator();
    while (badd.hasNext()) {
        getButtons().add(badd.next());
    }
    ListIterator<Button> it = getButtons().listIterator();
    while (it.hasNext()) {
        Button b = it.next();
        if (rbuttons.contains(b)) {
            it.remove();
        }
        if (b.getItem().equals(e.getCurrentItem()) && e.getInventory().equals(inv)) {
            b.onClick((Player) e.getWhoClicked(), e.getInventory());
            e.setCancelled(true);
        }
    }
}
项目:Ourtown    文件:SpawnGUI.java   
public void onInventoryClick(InventoryClickEvent event) {
    event.setCancelled(true);
    Player player = (Player) event.getWhoClicked();
    int slot = event.getRawSlot();
    if (event.getInventory().getSize() == 54 && slot >= 0 && slot < 54) {
        ItemStack item = event.getInventory().getItem(slot);
        if (slot >= 0 && slot < 45 && item != null && !item.getType().equals(Material.AIR)) {
            this.clickItem(player, event.getRawSlot(), event.isShiftClick());
            return;
        }
        if (event.getRawSlot() == 45 && event.getCurrentItem().getType() != Material.AIR) {
            this.openGUI(player, this.getCurrentPage() - 1);
        } else if (event.getRawSlot() == 53 && event.getCurrentItem().getType() != Material.AIR) {
            this.openGUI(player, this.getCurrentPage() + 1);
        } else {
            this.closeGUI(player);
        }
    } else {
        this.closeGUI(player);
    }
}
项目:ProjectAres    文件:PickerMatchModule.java   
@EventHandler(priority = EventPriority.LOWEST)
public void checkInventoryClick(InventoryClickEvent event) {
    if(event.getCurrentItem() == null ||
       event.getCurrentItem().getItemMeta() == null ||
       event.getCurrentItem().getItemMeta().getDisplayName() == null) return;

    match.player(event.getActor()).ifPresent(player -> {
        if(!this.picking.contains(player)) return;

        this.handleInventoryClick(
            player,
            ChatColor.stripColor(event.getCurrentItem().getItemMeta().getDisplayName()),
            event.getCurrentItem().getData()
        );
        event.setCancelled(true);
    });
}
项目:NeverLag    文件:GUISortPingListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onClickGUI(InventoryClickEvent e) {
    Inventory inv = e.getInventory();
    if (inv == null) {
        return;
    }
    if (i18n.tr("title").equals(inv.getTitle())) {
        e.setCancelled(true);
    }
    if (e.getWhoClicked() instanceof Player) {
        Player p = (Player) e.getWhoClicked();
        int slot = e.getRawSlot();
        if (slot < 0 || slot > inv.getSize()) {
            return;
        }
        GUISortPing guiSortPing = GUISortPingHolder.get(p);
        if (guiSortPing != null) {
            if (slot == 44) {
                p.openInventory(guiSortPing.getPreviousPage());
            } else if (slot == 53) {
                p.openInventory(guiSortPing.getNextPage());
            }
        }
    }
}
项目:ZentrelaCore    文件:MenuManager.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    UUID uuid = event.getWhoClicked().getUniqueId();
    if (invClickables.containsKey(uuid)) {
        HashMap<String, HashMap<String, Runnable>> invs = invClickables.get(uuid);
        String invName = event.getInventory().getName();
        if (invName != null && invs.containsKey(invName) && event.getCurrentItem() != null) {
            event.setCancelled(true);
            ((Player) event.getWhoClicked()).updateInventory();
            ItemStack item = event.getCurrentItem();
            String serialized = serializeForMenu(item);
            //                System.out.println("checking " + invs.get(invName) + " for " + serialized);
            if (invs.get(invName).containsKey(serialized)) {
                Runnable r = invs.get(invName).get(serialized);
                r.run();
            }
        }
    }
    if (event.getView() != null && event.getView().getBottomInventory() != null && event.getView().getBottomInventory() instanceof CraftInventoryPlayer) {
        if (event.getRawSlot() >= event.getView().getTopInventory().getSize() && generalClickables.containsKey(uuid)) {
            Player p = (Player) event.getWhoClicked();
            generalClickables.get(uuid).onClick(p, event.getCurrentItem(), event.getSlot());
        }
    }
}
项目:mczone    文件:CompassEvents.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    Player p = (Player) event.getWhoClicked();
    Inventory inv = event.getInventory();

    if (p.getGameMode() != GameMode.CREATIVE)
        event.setCancelled(true);

    if (Chat.stripColor(inv.getTitle()).equalsIgnoreCase("MC Zone Games")) {
        if (event.getRawSlot() > 9 || event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
            return;
        GameIcon game = GameIcon.get(event.getCurrentItem());
        if (game != null) {
            p.teleport(game.getTo());
            p.closeInventory();
        }
    }
}
项目:skLib    文件:ExprClickedItem.java   
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    if (mode == ChangeMode.SET) {
        ItemType item = (ItemType)delta[0];
        ItemStack m = item.getRandom();
        ((InventoryClickEvent)e).setCurrentItem(m);
    }
}
项目:BedwarsXP    文件:XPItemShop.java   
public void handleInventoryClick(InventoryClickEvent ice, Game game,
        Player player) {
    if (!hasOpenCategory())
        handleCategoryInventoryClick(ice, game, player);
    else
        handleBuyInventoryClick(ice, game, player);
}
项目:McLink    文件:ToggleButton.java   
@Override
public void onClick(Gui gui, InventoryClickEvent event) {
    this.enabled = !this.enabled;
    event.getCurrentItem().setDurability(getDataFromBoolean(this.enabled).getData());

    ItemMeta m = event.getCurrentItem().getItemMeta();
    m.setDisplayName(this.oname.replace("$nstate", enabled ? "Disable" : "Enable"));
    event.getCurrentItem().setItemMeta(m);

    event.setCancelled(true);
}
项目:FactionsXL    文件:IdeaMenu.java   
private void onGroupsClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    ItemStack button = event.getCurrentItem();
    event.setCancelled(true);
    PageGUI.playSound(event);
    IdeaGroup group = IdeaGroup.getByIcon(button);
    if (event.getClick() == ClickType.SHIFT_LEFT) {
        boolean selected = group.select(faction);
        MessageUtil.sendMessage(player, (selected ? FMessage.IDEA_MENU_GROUPS_SELECTED : FMessage.IDEA_MENU_GROUPS_DESELECTED).getMessage(group.getName()));
        openGroups(player);
    } else {
        openIdeas(player, group);
    }
}
项目:Crescent    文件:InventoryTweaksA.java   
@Override
public void call(Event event) {
    if (event instanceof InventoryClickEvent) {
        // The player has clicked.

        final Player player = profile.getPlayer();

        if (player.isSprinting() || player.isSneaking() || player.isBlocking() || player.isSleeping()
                || player.isConversing()) {
            // The player has clicked in their inventory impossibly.
            callback(true);
        }
    }
}
项目:McLink    文件:Page.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    for (RawItemPosition p : this.layout.getItems()) {
        if (event.getRawSlot() == p.calculatePosition() && this.compiles.contains(event.getInventory()) && p.getComponent() != null) {
            p.getComponent().onClick(this, event);
        }
    }
}
项目:HCFCore    文件:ModeratorMode.java   
@EventHandler
public void onInventoryClick(InventoryClickEvent e)
{
  Player p = (Player)e.getWhoClicked();
  if ((modMode.contains(p.getName())) && (p.getGameMode().equals(GameMode.CREATIVE))) {
    e.setCancelled(true);
  }
}
项目:McLink    文件:GuiSwitcher.java   
@Override
public void onClick(Gui gui, InventoryClickEvent event) {
    event.getWhoClicked().closeInventory();
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(McLink.instance, new Runnable() {

        @Override
        public void run() {
            event.getWhoClicked().openInventory(gui.compileItems());
        }

    }, 1L);
}
项目:uppercore    文件:MenuGui.java   
@Override
public void onClick(InventoryClickEvent event) {
    int slot = event.getSlot();
    if(slot < 0)
        return;
    Player clicker = (Player) event.getWhoClicked();
    int page = pageRegistry.getOrDefault(clicker, 0);
    Icon clicked = getIcon(page, slot);
    if(clicked != null)
        clicked.getClick().run(clicker);
}
项目:MCLibrary    文件:ClickHandler.java   
@Override
@SuppressWarnings("unchecked")
public void receive(GUIEvent event) {
    event.getEvent(GUIClickEvent.class).ifPresent(e -> {
        InventoryClickEvent clickEvent = (InventoryClickEvent) e;
        if (clickEvent.getAction() != InventoryAction.NOTHING &&
                (slots.isEmpty() || slots.contains(clickEvent.getRawSlot()))) {
            this.click(event);
        }
    });
}
项目:FactionsXL    文件:MilitaryMenu.java   
@EventHandler
public void onClick(InventoryClickEvent event) {
    HumanEntity player = event.getWhoClicked();
    Inventory inventory = event.getClickedInventory();
    if (inventory == null || gui == null || !gui.getTitle().equals(inventory.getTitle())) {
        return;
    }
    event.setCancelled(true);
    PageGUI.playSound(event);
    ItemStack button = event.getCurrentItem();
    if (BACK.equals(button)) {
        faction.getPopulationMenu().openMain(player);
        return;
    }
}