This is a port of JDA's AnnotatedEventManager so you can use the EventManager without any dependencies.
Updating from 1.0.0 to 1.1.0 might break your code
Maven
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.ForYaSee</groupId>
<artifactId>EventSystem</artifactId>
<version>1.1.0</version>
</dependency>
Gradle
repositories {
...
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.ForYaSee:EventSystem:v1.1.0'
}
YourEvent.java
// Your custom event you want to call
public class YourEvent implements Event {
private final yourVar...;
}
EventListener.java
//Your event listener
public class EventListener {
// Dont forget this annotation
@SubscribeEvent
public void onYourEvent(YourEvent event) {
// do smth
}
}
The class or method where you wanto to initialize the EventManager
// Optionally you can pass your own ExecutorService
EventManager eventManager = new EventManager();
// Register your event listener
eventManager.register(new EventListener());
// Call an event
eventManager.handle(new YourEvent(...));
// or async
eventManager.handleAsync(new YourEvent(...));