Can't use EventListener and ListenerAdapter at the same time. JDA forces itself to just use EventListener. It should at least throw an exception instead of being silently quiet.
public class DiscordBotMain {
public static void main(String[] args) {
JDA jda = new JDABuilder().setBotToken(###).buildBlocking();
jda.addEventListener(new DiscordBot());
}
}
public class DiscordBot extends ListenerAdapter implements EventListener {
@Override
public void onMessageReceived(MessageReceivedEvent event)
{
System.out.println("Message");
}
@Override
public void onEvent(Event event)
{
System.out.println("Event!");
}
}
It has nothing to do with not being able to use EventListener and ListenerAdapter at the same time. ListenerAdapter literally implements EventListener itself. You are re-implementing that method again.
Furthermore, the re-implementation isn't the problem. You're overriding the onEvent method from the ListenerAdapter and providing your own code. Of course the onEvent method in ListenerAdapter which serves all of those custom methods isn't going to fire correctly.
This is normal java stuff, not a fault of JDA. If you want to do stuff to ALL events before ListenerAdapter filters for you, then do
@Override
public void onEvent(Event event)
{
System.out.println("Event!");
super.onEvent(event);
}
Additionally, remove the unneeded implements EventListener from your DiscordBot class. ListenerAdapter implements it already.
Check the source of ListenerAdapter for more information.
Most helpful comment
It has nothing to do with not being able to use EventListener and ListenerAdapter at the same time. ListenerAdapter literally implements EventListener itself. You are re-implementing that method again.
Furthermore, the re-implementation isn't the problem. You're overriding the
onEventmethod from the ListenerAdapter and providing your own code. Of course theonEventmethod in ListenerAdapter which serves all of those custom methods isn't going to fire correctly.This is normal java stuff, not a fault of JDA. If you want to do stuff to ALL events before ListenerAdapter filters for you, then do
Additionally, remove the unneeded
implements EventListenerfrom your DiscordBot class. ListenerAdapter implements it already.Check the source of ListenerAdapter for more information.