diff options
Diffstat (limited to 'src/main/kotlin/me/bush/illnamethislater/Event.kt')
-rw-r--r-- | src/main/kotlin/me/bush/illnamethislater/Event.kt | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main/kotlin/me/bush/illnamethislater/Event.kt b/src/main/kotlin/me/bush/illnamethislater/Event.kt index dedd4df..476a34a 100644 --- a/src/main/kotlin/me/bush/illnamethislater/Event.kt +++ b/src/main/kotlin/me/bush/illnamethislater/Event.kt @@ -1,25 +1,34 @@ package me.bush.illnamethislater /** - * A base class for events that can be cancelled. More information can be found - * [here](https://github.com/therealbush/eventbus-kotlin) + * A base class for events that can be cancelled. * - * If [cancellable] is `true`, your event can be [cancelled], where future listeners will not receive it unless: - * * They have [Listener.receiveCancelled] set to `true`. - * * A previous listener with [Listener.receiveCancelled] sets [cancelled] back to `false` + * [Information and examples](https://github.com/therealbush/eventbus-kotlin#ththingtodo) * * @author bush * @since 1.0.0 */ abstract class Event { + + /** + * Whether this event is cancelled or not. If it is, only future listeners with + * [Listener.receiveCancelled] will receive it. However, it can be set back to + * `false`, and listeners will be able to receive it again. + */ var cancelled = false set(value) { if (cancellable) field = value } + /** + * Determines if this event can be [cancelled]. This does not have to return a constant value. + */ abstract val cancellable: Boolean + /** + * Sets [cancelled] to true. + */ fun cancel() { - cancelled = false + cancelled = true } } |