@EventHandler public void onInventoryMoveItem(InventoryInteractEvent event) { //System.out.println("E"); if (openchests.containsKey(event.getInventory())) { System.out.println("move"); openchests.get(event.getInventory()).getInventory().setContents(event.getInventory().getContents()); openchests.remove(event.getInventory()); } else { for (int i = 0; i < openchests.size(); i++) { Chest c = ((List<Chest>) openchests.values()).get(i); if (c.getInventory().equals(event.getInventory())) { ((List<Inventory>) openchests.keySet()).get(i).setContents(event.getInventory().getContents()); } } } }
public BasicMenu(final Minigame minigame, int rows, String title, final EventListener<InventoryClickEvent> onClick) { Validate.notNull(minigame, "Minigame cannot be null"); Validate.isTrue(rows >= 1 && rows <= 9, "Rows must be an integer between 1-9, inclusive"); this.size = rows * 9; if (title == null) title = ""; this.inv = Bukkit.createInventory(null, size, title); if (onClick != null) { minigame.listenEvent(new EventListener<InventoryInteractEvent>() { @Override public void onEvent(InventoryInteractEvent event) { HumanEntity human = event.getWhoClicked(); if (!(human instanceof Player) || !minigame.isPlaying(((Player) human))) return; if (!(event instanceof InventoryClickEvent)) { event.setCancelled(true); return; } InventoryClickEvent e = (InventoryClickEvent) event; if (inv.equals(e.getClickedInventory())) onClick.onEvent(e); } }); } }
@EventHandler public void onInteract(InventoryInteractEvent e) { if(GUIWindow.windows.containsKey(e.getInventory().getTitle())){ e.setResult(Event.Result.DENY); e.setCancelled(true); } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onInventoryInteract(InventoryInteractEvent e) { Player player = (Player) e.getWhoClicked(); if (plugin.pm.isGhost(player)) { e.setCancelled(true); player.closeInventory(); } }
@EventHandler public void onInventoryInteract(InventoryInteractEvent event) { Player clicker = (Player) event.getWhoClicked(); Inventory view = event.getInventory(); if ((view.equals(clicker))) { event.setCancelled(true); } }
@EventHandler public void onInventoryInteract(InventoryInteractEvent event) { if (!event.getWhoClicked().isOp()) event.setCancelled(true); }
public PagedMenu(final MinigameShell minigame, int pageRows, int pages, String title, final ItemStack backItem, final ItemStack nextItem, final EventListener<InventoryClickEvent> onClick) { Validate.notNull(minigame, "Minigame cannot be null"); Validate.isTrue(pageRows > 0 && pageRows <= 9, "There must be between 1-9 rows, inclusive, per page"); Validate.isTrue(pages > 0, "There must be at least 1 page"); if (title == null) title = ""; Validate.notNull(backItem, "The \"back\" item cannot be null"); Validate.notNull(nextItem, "The \"next\" item cannot be null"); this.invs = new Inventory[pages]; this.backItem = backItem; this.nextItem = nextItem; this.shell = minigame; for (int i = 0; i < pages; i++) this.invs[i] = Bukkit.createInventory(null, pageRows * 9, String.format(title, i + 1)); if (onClick != null) { EventListener<InventoryInteractEvent> listener = new EventListener<InventoryInteractEvent>() { @Override public void onEvent(InventoryInteractEvent event) { HumanEntity human = event.getWhoClicked(); if (minigame != null && minigame instanceof Minigame) if (!(human instanceof Player) || !((Minigame) minigame).isPlaying(((Player) human))) return; if (!(event instanceof InventoryClickEvent)) { event.setCancelled(true); return; } InventoryClickEvent e = (InventoryClickEvent) event; for (int i = 0; i < invs.length; i++) { if (invs[i].equals(e.getClickedInventory())) { ItemStack item = e.getCurrentItem(); Player player = (Player) human; if (backItem.equals(item)) player.openInventory(invs[i - 1]); else if (nextItem.equals(item)) player.openInventory(invs[i + 1]); else onClick.onEvent(e); } } } }; // if we have a minigame instance, lets create the menu listeners based off of it if (minigame instanceof Minigame) ((Minigame) minigame).listenEvent(listener); else // otherwise, we can use a generic empty shell (warning: persists until plugin deactivates!!!!!) MinigameManager.getMinigameManager().addListener(shell, InventoryInteractEvent.class, listener); } }
@EventHandler public void onInventoryInteract(InventoryInteractEvent event) { if (event.getInventory().getHolder() instanceof Block) { processEvent(event, (Player) event.getWhoClicked()); } }
@EventHandler public void onInventoryAction(final InventoryInteractEvent event) { if (event.getInventory().getHolder() instanceof InfoInventory) { event.setResult(Event.Result.DENY); } }
public void onInventoryInteract(InventoryInteractEvent event) { event.setCancelled(true); }
@Override public void eventTrigger(Event event) { if(event.getEventName().equalsIgnoreCase("playerjoinevent")){ eh.onPlayerJoin((PlayerJoinEvent)event); } else if(event.getEventName().equalsIgnoreCase("playerdropitemevent")){ eh.onPlayerDrop((PlayerDropItemEvent)event); } else if(event.getEventName().equalsIgnoreCase("playerinteractevent")){ eh.onPlayerInteract((PlayerInteractEvent)event); } else if(event.getEventName().equalsIgnoreCase("inventoryclickevent")){ eh.onInventoryClick((InventoryClickEvent)event); } else if(event.getEventName().equalsIgnoreCase("playertoggleflightevent")){ eh.onPlayerToggleFlight((PlayerToggleFlightEvent)event); } else if(event.getEventName().equalsIgnoreCase("playermoveevent")){ eh.onPlayerMove((PlayerMoveEvent)event); } else if(event.getEventName().equalsIgnoreCase("playerdropitemevent")){ eh.onPlayerDrop((PlayerDropItemEvent) event); } else if(event.getEventName().equalsIgnoreCase("playerinteractentityevent")){ eh.onPlayerInteractEntity((PlayerInteractEntityEvent) event); } else if(event.getEventName().equalsIgnoreCase("entitydamagebyentityevent")){ eh.onEntityDamageByEntity((EntityDamageByEntityEvent) event); } else if(event.getEventName().equalsIgnoreCase("playerquitevent")){ eh.onPlayerLeave((PlayerQuitEvent) event); } else if(event.getEventName().equalsIgnoreCase("foodlevelchangeevent")){ eh.onFoodLevelChange((FoodLevelChangeEvent) event); } else if(event.getEventName().equalsIgnoreCase("entitydamageevent")){ eh.onEntityDamage((EntityDamageEvent) event); } else if(event.getEventName().equalsIgnoreCase("weatherchangeevent")){ eh.onWeatherChange((WeatherChangeEvent) event); } else if(event.getEventName().equalsIgnoreCase("inventoryinteractevent")){ eh.onInventoryInteract((InventoryInteractEvent) event); } else if(event.getEventName().equalsIgnoreCase("worldloadevent")){ eh.onWorldLoad((WorldLoadEvent) event); } }
public void onInteract(InventoryInteractEvent e) { if (e.getWhoClicked() instanceof Player) { e.getWhoClicked().getLocation().getWorld().getName(); } }