net.dv8tion.jda.api.events.Event Java Examples
The following examples show how to use
net.dv8tion.jda.api.events.Event.
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: ContextEventManagerImpl.java From JuniperBot with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") private <T extends Event> void dispatchChain(Class<T> type, T event) { EventFilterFactory<T> factory = (EventFilterFactory<T>) filterFactoryMap.get(type); if (factory == null) { return; } FilterChain<T> chain = factory.createChain(event); if (chain == null) { return; } try { chain.doFilter(event); } catch (Exception e) { log.error("Could not process filter chain", e); } }
Example #2
Source File: EventUtils.java From MantaroBot with GNU General Public License v3.0 | 5 votes |
public static void propagateEvent(MantaroEvent event) { for (var shard : MantaroBot.getInstance().getShardManager().getShards()) { shard.getEventManager().handle((Event) event); } event.onPropagation(); }
Example #3
Source File: AnnotatedEventManager.java From JDA with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public void handle(@Nonnull GenericEvent event) { Class<?> eventClass = event.getClass(); do { Map<Object, List<Method>> listeners = methods.get(eventClass); if (listeners != null) { listeners.forEach((key, value) -> value.forEach(method -> { try { method.setAccessible(true); method.invoke(key, event); } catch (IllegalAccessException | InvocationTargetException e1) { JDAImpl.LOG.error("Couldn't access annotated EventListener method", e1); } catch (Throwable throwable) { JDAImpl.LOG.error("One of the EventListeners had an uncaught exception", throwable); if (throwable instanceof Error) throw (Error) throwable; } })); } eventClass = eventClass == Event.class ? null : (Class<? extends GenericEvent>) eventClass.getSuperclass(); } while (eventClass != null); }