aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt
blob: c7c8ea66aa1cb22e0249519057bf1b6ca851f97e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.dulkirfabric.events.base

import com.dulkirfabric.DulkirModFabric
import meteordevelopment.orbit.ICancellable

abstract class CancellableEvent: ICancellable {
    private var cancelled = false

    override fun isCancelled(): Boolean {
        return cancelled
    }

    override fun setCancelled(cancelled: Boolean) {
        this.cancelled = cancelled
    }

    /**
     * Posts a given event to the bus and returns whether the user wishes to cancel it
     */
    fun post(): Boolean {
        return DulkirModFabric.EVENT_BUS.post(this).isCancelled
    }
}