EventBuilder

class EventBuilder<T : Event>(val plugin: Plugin, val type: Class<T>, var priority: EventPriority = EventPriority.NORMAL, var ignoreCancelled: Boolean = false)

A DSL builder for handling Bukkit events.

Parameters

T

The type of the event.

plugin

The plugin instance.

type

The class of the event.

priority

The priority of the event listener (default: NORMAL).

ignoreCancelled

Whether to ignore cancelled events (default: false).

Constructors

Link copied to clipboard
constructor(plugin: Plugin, type: Class<T>, priority: EventPriority = EventPriority.NORMAL, ignoreCancelled: Boolean = false)

Properties

Link copied to clipboard
Link copied to clipboard
val plugin: Plugin
Link copied to clipboard
var priority: EventPriority
Link copied to clipboard
val type: Class<T>

Functions

Link copied to clipboard
fun T.cancel()

Cancels the event if it is Cancellable.

Link copied to clipboard

Enables debug mode for this listener.

Link copied to clipboard
fun expireAfter(seconds: Long): EventBuilder<T>

Automatically unregisters the listener after a specified number of seconds.

Link copied to clipboard
fun filter(predicate: T.() -> Boolean): EventBuilder<T>

Adds a filter condition to the event handler.

Link copied to clipboard
fun filterPlayer(predicate: Player.() -> Boolean): EventBuilder<T>

Filters the event based on the player associated with it (only for PlayerEvent).

Link copied to clipboard
fun handle(action: T.() -> Unit): EventBuilder<T>

Defines the action to be performed when the event is handled. Calling this method will register the listener.

Link copied to clipboard

Configures the listener to unregister itself after the first successful execution.

Link copied to clipboard
fun take(times: Int): EventBuilder<T>

Configures the listener to unregister itself after a certain number of executions.

Link copied to clipboard
fun takeWhile(predicate: T.() -> Boolean): EventBuilder<T>

Keeps the listener registered as long as the predicate returns true.

Link copied to clipboard

Manually unregisters the listener.