of

fun <T : Event> of(eventType: Class<T>, handler: Consumer<T>): EventListener<T>

Creates a new event listener that listens for events of the given eventType, running the given handler when an event of the correct type is fired.

Return

a new event listener

Parameters

T

the type of event

eventType

the type of events the listener will listen for

handler

the handler for the listener