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

项目:McLink    文件:ActionBind.java   
@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());
            }
        }
    }
}
项目:MinigameManager    文件:BasicMenu.java   
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);
            }
        });
    }
}
项目:SpigotItemGenerator    文件:GUIListener.java   
@EventHandler
public void onInteract(InventoryInteractEvent e) {
    if(GUIWindow.windows.containsKey(e.getInventory().getTitle())){
        e.setResult(Event.Result.DENY);
        e.setCancelled(true);
    }
}
项目:libelula    文件:EventManager.java   
@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();
    }

}
项目:Rixor    文件:FilterEvents.java   
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event) {
    Player clicker = (Player) event.getWhoClicked();
    Inventory view = event.getInventory();
     if ((view.equals(clicker))) {
         event.setCancelled(true);
     }
}
项目:Hub    文件:PlayerListener.java   
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event)
{
    if (!event.getWhoClicked().isOp())
        event.setCancelled(true);
}
项目:MinigameManager    文件:PagedMenu.java   
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);
    }
}
项目:Steel    文件:PlayerWorldListener.java   
@EventHandler
public void onInventoryInteract(InventoryInteractEvent event) {
    if (event.getInventory().getHolder() instanceof Block) {
        processEvent(event, (Player) event.getWhoClicked());
    }
}
项目:PlotSquared-Chinese    文件:InventoryListener.java   
@EventHandler
public void onInventoryAction(final InventoryInteractEvent event) {
    if (event.getInventory().getHolder() instanceof InfoInventory) {
        event.setResult(Event.Result.DENY);
    }
}
项目:gFeatures    文件:EventHub.java   
public void onInventoryInteract(InventoryInteractEvent event) {
    event.setCancelled(true);
}
项目:gFeatures    文件:gHub.java   
@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);
    }
}
项目:SuperSkyBros    文件:InventoryInteract.java   
public void onInteract(InventoryInteractEvent e) {

        if (e.getWhoClicked() instanceof Player) {
            e.getWhoClicked().getLocation().getWorld().getName();
        }

    }