Ef4j
About the project
Ef4j (Event Framework For Java) - Simple and lightweight event framework
Benchmarks
TODO
Example
class MyListener {
@EventHandler
public void listen(MyEvent event) {
System.out.println(event.getMessage());
}
}
class MyEvent extends Event {
private final String message;
public MyEvent(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
EventBus bus = new ConcurrentEventBus();
// register listener
bus.subscribe(new MyListener());
// send event to all listeners
bus.publish(new MyEvent("Hello world!"));
You can to specify the EventNamespace to EventBus#subscribe and then you will be able to remove all listeners by that EventNamespace using EventBus#unsubscribeAll(EventNamespace)
Also you can set EventHandler's priority, just use @EventHandler(EventPriority.<...>)
There are 6 types of priority:
LOWESTwill be executed firstLOWwill be executed afterLOWESTNORMALwill be executed afterLOW(default)HIGHwill be executed afterNORMALHIGHESTwill be executed afterHIGHMONITORwill be executed last
Add as dependency
Maven
<dependencies>
<dependency>
<groupId>com.github.lero4ka16</groupId>
<artifactId>ef4j</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
Gradle
dependencies {
implementation 'com.github.lero4ka16:ef4j:1.1.0'
}
Build the project
- Execute
./gradlew build - Output file located at
build/libs/ef4j.jar
Contact
Post Scriptum
I will be very glad if someone can help me with development.