diff --git a/src/main/java/com/seailz/discordjar/events/EventDispatcher.java b/src/main/java/com/seailz/discordjar/events/EventDispatcher.java index b1e9d890..b1509501 100644 --- a/src/main/java/com/seailz/discordjar/events/EventDispatcher.java +++ b/src/main/java/com/seailz/discordjar/events/EventDispatcher.java @@ -55,7 +55,15 @@ public void addListener(DiscordListener... listeners) { for (DiscordListener listener : listeners) { for (Method method : listener.getClass().getMethods()) { if (method.isAnnotationPresent(EventMethod.class)) { - Class eventType = (Class) method.getParameterTypes()[0]; + Class maybeEventType = method.getParameterTypes()[0]; + + if (!Event.class.isAssignableFrom(maybeEventType)) + throw new IllegalArgumentException(String.format("%s first arg is not of Event", method)); + else if (method.getParameterTypes().length != 1) + throw new IllegalArgumentException(String.format("%s#%s is an invalid listener", method.getDeclaringClass(), method.getName())); + + @SuppressWarnings("unchecked") + Class eventType = (Class) maybeEventType; EventMethod eventMethod = method.getAnnotation(EventMethod.class); String customId = null;