Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 2.25 KB

README.md

File metadata and controls

97 lines (74 loc) · 2.25 KB

[Java CI] [Latest Version]

JEvent

JEvent provides a powerful and lightweight event system based on the syntax of the Spigot Event System.

Usage

public class MyEvent extends Event {
	private String name;
	
	public MyEvent(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}

public class MyListener {

	@EventHandler //marks the Method as EventHandler method
	//the parameter is the Event the handler should listen to
	public void onEvent(MyEvent event) {
		System.out.println("Event name: " + event.getName());
		//change the event data
		event.setName("Edited " + event.getName());
	}

}

public class Main {
	public static void main(String[] args) {
		//get the default Event manager
		EventManager manager = JEvent.getDefaultManager();

		//register the listener
		manager.registerListener(MyListener.class);
		//or
		manager.registerListener(new MyListener());

		//initialize Event
		MyEvent event = new MyEvent("MyEventName");
		
		System.out.println(event.getName()); //"MyEventName"
		
		//call Event
		manager.callEvent(event);
		//or
		event.callEvent(); //only possible on the default manager

		System.out.println(event.getName()); //"Edited MyEventName"
	}
}

Installation

JEvent is hosted on a custom repository at https://maven.mineking.dev. Replace VERSION with the lastest version (without the v prefix). Alternatively, you can download the artifacts from jitpack (not recommended).

Gradle

repositories {
  maven { url "https://maven.mineking.dev/releases" }
}

dependencies {
  implementation "de.cyklon:JEvent:VERSION"
}

Maven

<repositories>
  <repository>
    <id>cyklon</id>
    <url>https://maven.mineking.dev/releases</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>de.cyklon</groupId>
    <artifactId>JEvent</artifactId>
    <version>VERSION</version>
  </dependency>
</dependencies>