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

下面列出了怎么用org.bukkit.event.inventory.InventoryEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: IF   文件: Gui.java
/**
 * Calls the specified consumer (if it's not null) with the specified parameter,
 * catching and logging all exceptions it might throw.
 *
 * @param callback the consumer to call if it isn't null
 * @param event the value the consumer should accept
 * @param callbackName the name of the action, used for logging
 * @param <T> the type of the value the consumer is accepting
 */
private <T extends InventoryEvent> void callCallback(@Nullable Consumer<T> callback,
        @NotNull T event, @NotNull String callbackName) {
    if (callback == null) {
        return;
    }

    try {
        callback.accept(event);
    } catch (Throwable t) {
        Logger logger = JavaPlugin.getProvidingPlugin(getClass()).getLogger();
        String message = "Exception while handling " + callbackName + " in inventory '" + title + "', state=" + state;
        if (event instanceof InventoryClickEvent) {
            InventoryClickEvent clickEvent = (InventoryClickEvent) event;
            message += ", slot=" + clickEvent.getSlot();
        }
        logger.log(Level.SEVERE, message, t);
    }
}
 
源代码2 项目: TabooLib   文件: ClickEvent.java
public Inventory getInventory() {
    return ((InventoryEvent) event).getInventory();
}
 
 类所在包
 类方法
 同包方法