Skip to content

Event DSL

MattMX edited this page Nov 22, 2023 · 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:

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

To create a welcome message on login we can do this

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

Inside the plugin class you do not need to provide the instance of the plugin as a parameter.

Clone this wiki locally