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

项目:MCLibrary    文件:TopHandler.java   
@Override
public void onEvent(InventoryEvent event) {
    if (event instanceof InventoryClickEvent) {
        InventoryClickEvent clickEvent = ((InventoryClickEvent) event);
        if (isTop(event, clickEvent.getRawSlot())) {
            notify(event);
        }
    } else if (event instanceof InventoryDragEvent) {
        InventoryDragEvent dragEvent = ((InventoryDragEvent) event);
        for (int slot : dragEvent.getRawSlots()) {
            if (isTop(event, slot)) {
                notify(event);
                break;
            }
        }
    }
}
项目:MCLibrary    文件:TopInventoryHandler.java   
@Override
public void handle(GUIEvent<InventoryEvent> event) {
    InventoryEvent nativeEvent = event.getEvent();
    if (nativeEvent instanceof InventoryClickEvent) {
        InventoryClickEvent clickEvent = (InventoryClickEvent) nativeEvent;
        if (clickEvent.getRawSlot() < clickEvent.getInventory().getSize())
            receive(event);
    } else if (nativeEvent instanceof InventoryDragEvent) {
        InventoryDragEvent dragEvent = (InventoryDragEvent) nativeEvent;
        for (int slot : dragEvent.getRawSlots()) {
            if (slot < dragEvent.getInventory().getSize()) {
                receive(event);
                break;
            }
        }
    }
}
项目:PV-Star    文件:ArenaEventForwarder.java   
@Override
protected void onInventoryEvent(InventoryEvent event) {
    if (event instanceof EnchantItemEvent) {
        callEvent(((EnchantItemEvent) event).getEnchanter(), event);
    }
    else if (event instanceof PrepareItemEnchantEvent) {

        callEvent(((PrepareItemEnchantEvent) event).getEnchanter(), event);
    }
    else {
        InventoryHolder holder = event.getInventory().getHolder();

        if (holder instanceof Player) {
            callEvent((Player)holder, event);
        }
    }
}
项目:MCLibrary    文件:GUIEvent.java   
@SuppressWarnings("unchecked")
public <T extends InventoryEvent> Optional<T> getEvent(Class<T> eventClass) {
    E event = getEvent();
    return eventClass.isInstance(event) ?
            Optional.ofNullable((T) event) :
            Optional.empty();
}
项目:MCLibrary    文件:PagingInventoryProcessor.java   
@Override
public void receive(GUIEvent<InventoryEvent> guiEvent) {
    guiEvent.getEvent(GUIClickEvent.class).ifPresent(click -> {
        if (click.getRawSlot() >= size)
            click.setCancelled(true);
    });
}
项目:MCLibrary    文件:PagingInventoryProcessor.java   
@Override
public void handle(GUIEvent<InventoryEvent> event) {
    event.getEvent(GUIClickEvent.class).ifPresent(e -> {
        int slot = e.getRawSlot();
        if (slot >= 0 && slot < size) {
            e.setRawSlot(e.getRawSlot() + (currentPage - 1) * size);
        }
        if (slot >= size)
            event.setConsume(true);
    });
}
项目:MCLibrary    文件:GUIHandlers.java   
public void notify(InventoryEvent event) {
    GUIEvent<InventoryEvent> guiEvent = new GUIEvent<>(gui, convert(event));
    for (GUIHandler handler : handlers) {
        handler.handle(guiEvent);

        if (guiEvent.isConsume())
            break;
    }
}
项目:NucleusFramework    文件:BukkitEventForwarder.java   
public void on(Object e) {

            if (!(e instanceof Event))
                return;

            Event event = (Event) e;

            onEvent(event);

            if (event instanceof PlayerEvent) {
                onPlayerEvent((PlayerEvent)event);
            }
            else if (event instanceof BlockEvent) {
                onBlockEvent((BlockEvent)event);
            }
            else if (event instanceof HangingEvent) {
                onHangingEvent((HangingEvent)event);
            }
            else if (event instanceof InventoryEvent) {
                onInventoryEvent((InventoryEvent) event);
            }
            else if (event instanceof VehicleEvent) {
                onVehicleEvent((VehicleEvent) event);
            }
            else if (event instanceof EntityEvent) {
                onEntityEvent((EntityEvent) event);
            }
        }
项目:SkyWars    文件:KitGuiListener.java   
private boolean isKitGuiInvolved(InventoryEvent evt) {
    Inventory inventory = evt.getInventory();
    InventoryHolder holder = inventory.getHolder();
    if (holder instanceof Player) {
        if (((Player) holder).getOpenInventory().getTitle().equals(plugin.getKitGui().getKitGuiTitle())) {
            // This ensure that a player is unable to manipulate their own items when a kit GUI is open.
            return true;
        }
    }
    return inventory.getTitle().equals(plugin.getKitGui().getKitGuiTitle());
}
项目:MCLibrary    文件:TopHandler.java   
public static boolean isTop(InventoryEvent event, int slot) {
    Inventory topInv = event.getInventory();
    return topInv != null && slot >= 0 && slot <= topInv.getSize();
}
项目:MCLibrary    文件:TopHandler.java   
@SafeVarargs
public final TopHandler addHandler(GUIHandler<InventoryEvent>... handlers) {
    this.handlers.addAll(Arrays.asList(handlers));
    return this;
}
项目:MCLibrary    文件:TopHandler.java   
private void notify(InventoryEvent event) {
    handlers.forEach(handler -> handler.onEvent(event));
}
项目:MCLibrary    文件:CancelHandler.java   
@Override
public void onEvent(InventoryEvent event) {
    if (event instanceof Cancellable) {
        ((Cancellable) event).setCancelled(true);
    }
}
项目:MCLibrary    文件:GUIHandlers.java   
@SafeVarargs
public final GUIHandlers add(GUIHandler<InventoryEvent>... handlers) {
    this.handlers.addAll(Arrays.asList(handlers));
    return this;
}
项目:MCLibrary    文件:GUIHandlers.java   
public void notify(InventoryEvent event) {
    handlers.forEach(handler -> handler.onEvent(event));
}
项目:MCLibrary    文件:GUIHandlers.java   
private InventoryEvent convert(InventoryEvent event) {
    if (event instanceof InventoryClickEvent) {
        event = new GUIClickEvent((InventoryClickEvent) event, gui);
    }
    return event;
}
项目:RpgPlus    文件:InventoryEventManagerImpl.java   
protected void callHandlers(String eventName, InventoryEvent event) {
    callHandlers(eventName, event, event.getInventory());
}
项目:gFeatures    文件:Library.java   
public void onInventory(InventoryEvent event) {
    check("onInventory", event);
}
项目:gFeatures    文件:Listeners.java   
@EventHandler
public void InventoryEvent(InventoryEvent event){
    library.onInventory(event);
}
项目:SyncChest    文件:InventoryListener.java   
@EventHandler
   public void onOtherInteraction(InventoryEvent event) {
if (event.getInventory().getTitle().contains("MainChest") || event.getInventory().getTitle().contains("RelatedChest")) {
    SyncManager.getManager().updateHoppers();
}
   }
项目:quick-game-framework    文件:ArenaBase.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onInventoryEvent(InventoryEvent evt) {
    checkLocation(evt.getView().getPlayer().getLocation(), evt);
}
项目:NucleusFramework    文件:BukkitEventForwarder.java   
/**
 * Invoked whenever a registered inventory event is called.
 *
 * <p>Intended for optional override.</p>
 *
 * @param event  The called event.
 */
protected void onInventoryEvent(InventoryEvent event) {}
项目:MCLibrary    文件:GUIHandler.java   
void handle(GUIEvent<InventoryEvent> event);
项目:MCLibrary    文件:TopInventoryHandler.java   
public abstract void receive(GUIEvent<InventoryEvent> event);