-
Notifications
You must be signed in to change notification settings - Fork 19
EventSubscriber
Hakan Kargın edited this page May 26, 2022
·
4 revisions
With this feature you don't need to use class to register any listener.
You can register any listener at anywhere. Also, you can define use limit, filters and expire time of registered event.
HCore.registerEvent(PlayerJoinEvent.class) //registers PlayerJoinEvent
.priority(EventPriority.HIGHEST) //sets priority as HIGHEST
.expire(10, TimeUnit.HOURS) //this event will expire in 10 hours
.filter(event -> event.getPlayer().hasPermission("example.permission")) //adds filter to work this listener
.limit(10) //after 10 usage, this listener will unregister (Events that fail the filter do not affects the limit!)
.consume(event -> { //when the event is triggered, consume will work
event.getPlayer().sendMessage("test");
event.getPlayer().sendMessage("test");
event.getPlayer().sendMessage("test");
});