Skip to content

Commit

Permalink
Updated to use new EventBus System...
Browse files Browse the repository at this point in the history
  • Loading branch information
RealMangorage committed May 23, 2024
1 parent 9124bf5 commit e686415
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'

installer('org.mangorage:installer:3.0.22')
bot('org.mangorage:mangobot:+')
bot('org.mangorage:mangobot:10.0.409')

library('org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5')
library('org.kohsuke:github-api:1.321')
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/mangorage/mangobot/MangoBotPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Scanner;
import java.util.Timer;
import java.util.TimerTask;

import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
Expand Down Expand Up @@ -174,7 +172,7 @@ public MangoBotPlugin() {

getJDA().addEventListener(new BotEventListener(this));

getPluginBus().addGenericListener(100, MessageReceivedEvent.class, DiscordEvent.class, this::onMessage2);
getPluginBus().addGenericListener(10, MessageReceivedEvent.class, DiscordEvent.class, this::onMessage2);
}

public void onMessage2(DiscordEvent<MessageReceivedEvent> event) {
Expand Down Expand Up @@ -289,7 +287,7 @@ public void registration() {
});

new Listeners(this);
getPluginBus().addGenericListener(10, MessageReceivedEvent.class, DiscordEvent.class, this::onMessage);
getPluginBus().addGenericListener(10, MessageReceivedEvent.class, DiscordEvent.class, this::onMessage);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
import net.dv8tion.jda.api.events.session.SessionResumeEvent;
import net.dv8tion.jda.api.hooks.SubscribeEvent;
import org.mangorage.basicutils.LogHelper;
import org.mangorage.eventbus.interfaces.IEventBus;
import org.mangorage.jdautils.WatcherManager;
import org.mangorage.mangobotapi.core.events.DiscordEvent;
import org.mangorage.mangobotapi.core.events.discord.DMessageReceivedEvent;
import org.mangorage.mangobotapi.core.plugin.api.CorePlugin;
import org.mangorage.mboteventbus.impl.IEventBus;


@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@
import org.eclipse.egit.github.core.service.GistService;
import org.mangorage.basicutils.TaskScheduler;
import org.mangorage.basicutils.misc.LazyReference;
import org.mangorage.eventbus.interfaces.IEventBus;
import org.mangorage.mangobot.MangoBotPlugin;
import org.mangorage.mangobot.modules.logs.BrokenDrivers;
import org.mangorage.mangobot.modules.logs.EarlyWindow;
import org.mangorage.mangobot.modules.logs.Java22;
import org.mangorage.mangobot.modules.logs.LogAnalyser;
import org.mangorage.mangobot.modules.logs.MissingDeps;
import org.mangorage.mangobotapi.core.events.DiscordEvent;
import org.mangorage.mboteventbus.impl.IEventBus;

import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.entities.emoji.Emoji;
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/org/mangorage/test/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.mangorage.test;

import org.mangorage.eventbus.EventBus;
import org.mangorage.mangobotapi.core.events.SaveEvent;

public class test {
public static void main(String[] args) {
var bus = EventBus.create();

bus.addListener(10, SaveEvent.class, test::onSave);
bus.post(new SaveEvent());
}

public static void onSave(SaveEvent e) {
System.out.println("LOL");
}
}

0 comments on commit e686415

Please sign in to comment.