@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); } } } } }
@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); } } } } }
@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()); }
/** * 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); } } }
@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); }
@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); }); }
@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); } } } }
/** * 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(); } }
@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()); }
@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(); } } }
/** * 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; } }
/** * 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; }
@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); } }
@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); } } } }
@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); } } }
@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); }
@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; } } } }
@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); }
@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); } } } } }
@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); }
@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); } } } } } }
/** * 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); } }
@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); } } } }
@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); } } }
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); } }
@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); }); }
@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()); } } } }
@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()); } } }
@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(); } } }
@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); } }
public void handleInventoryClick(InventoryClickEvent ice, Game game, Player player) { if (!hasOpenCategory()) handleCategoryInventoryClick(ice, game, player); else handleBuyInventoryClick(ice, game, player); }
@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); }
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); } }
@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); } } }
@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); } } }
@EventHandler public void onInventoryClick(InventoryClickEvent e) { Player p = (Player)e.getWhoClicked(); if ((modMode.contains(p.getName())) && (p.getGameMode().equals(GameMode.CREATIVE))) { e.setCancelled(true); } }
@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); }
@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); }
@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); } }); }
@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; } }