Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Latest commit

 

History

History
83 lines (61 loc) · 1.59 KB

README.md

File metadata and controls

83 lines (61 loc) · 1.59 KB

Annotated Events

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

Download

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'
}

How to use?

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(...));