Flyte Documentation 0.0.2 Help

Events

Twilight has a short method of creating events which automatically register. We personally use this method in the Kotlin init {} method.

You can make use of it like so:

event<PlayerJoinEvent> { player.sendMessage("Welcome to the server!") }

The function also provides more arguments which are optional which are shown below:

// "true" is the ignoreCancelled argument event<PlayerJoinEvent>(EventPriority.HIGHEST, true) { player.sendMessage("Welcome to the server!") }

If you ever need an instance of the Listener class that the event gets put in to, it's returned by the function. Specifically, it returns TwilightListener. This class has a convenience function in for unregistering the listener, it can be used like so:

val listener = event<PlayerJoinEvent> { player.sendMessage("Welcome to the server!") } listener.unregister()
Last modified: 21 February 2024