org.bukkit.event.inventory.InventoryEvent Java Examples
The following examples show how to use
org.bukkit.event.inventory.InventoryEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Gui.java From IF with The Unlicense | 6 votes |
/** * 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); } }
Example #2
Source File: ClickEvent.java From TabooLib with MIT License | 4 votes |
public Inventory getInventory() { return ((InventoryEvent) event).getInventory(); }