Skip to content

Event DSL

MattMX edited this page Nov 15, 2022 · 3 revisions

What does it do

The Event DSL allows us to create event listeners with ease, not needing to create a class for listeners.

Create a listener

The structure of a DSL event listener is as follows:

onEvent<Event>(plugin instance) {
  // your code here
}

To create a welcome message on login we can do this

// where "this" is the plugin instance
onEvent<PlayerJoinEvent>(this) {
  player.sendMessage("&7Welcome back &c${player.name}".color())
}
Clone this wiki locally