Skip to content

Events (v2)

Elikill58 edited this page Jun 20, 2022 · 2 revisions

General

For the V2, Negativity use a custom event system, to make events available for every platform (and not spigot events for spigot, and sponge events for sponge).

All events are located at com.elikill58.negativity.api.events.

It works approximatly the same as spigot.

How to register own listener ?

Firstly, you have to implement Listeners.

Then, when you want to intercept an event, you have to create a method with only one argument : the needed event.

To this method, you have to add @EventListener as @EventHandler on spigot and @Listener on sponge.

Finally, you have to register this class to Negativity event manager :

EventManager.registerEvent(myClass)

Wow, there is a lot of events !

Yes. Negativity as all of his own events, as PlayerMoveEvent, InventoryClickEvent ... and not only cheaters one.

How to call custom events ?

You have to create a new class which implement Event.

Then call EventManager.callEvent(myEvent)