Light weight and simple library to create spigot events in the go. I created this api since I find the spigot APIs incredible tedious to use and also leads to a lot of boilerplate code...
Usage
First, to use the api, you need to register your plugin
Code (Java):
@Override
public
void onEnable
(
)
{
JEvents.
register
(
this
)
;
}
jEvents provides a very simple event creation abstraction. Here is an example:
Code (Java):
JEvents.
subscribe
(InventoryClickEvent.
class
)
// The class of the event you want to listen
.
handler
(event
->
{
event.
setCancelled
(
true
)
;
// Do something here
}
)
;
As you can see, the creation of a listener is way easier than spigot's API, you just need specify the Event class, and
you are good to go
More examples of the api usage:
Code (Java):
JEvents.
subscribe
(InventoryClickEvent.
class
)
.
filter
(event
-> event.
getInventory
(
).
equals
(myInv
)
)
// Only apply the action inside the handler
.
filter
(event
-> event.
getSlot
(
)
==
3
)
// if the filters are met
.
handler
(event
->
{
event.
setCancelled
(
true
)
;
// Do something here
}
)
;
Code (Java):
JEvents.
subscribe
(PlayerDeathEvent.
class
)
.
biHandler
(
(subscription, playerDeathEvent
)
->
{
playerDeathEvent.
setDeathMessage
(
"Ha you died loser"
)
;
subscription.
unregister
(
)
;
// Unregisters the listener
}
)
;