From c0eb625a9b937bcb9256e98afb80d32443daa795 Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 9 Jun 2023 16:55:24 -0500 Subject: 1.20 refactor --- .../dulkirfabric/events/base/CancellableEvent.kt | 25 ++++++++++++++++++++++ .../kotlin/com/dulkirfabric/events/base/Event.kt | 9 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt create mode 100644 src/main/kotlin/com/dulkirfabric/events/base/Event.kt (limited to 'src/main/kotlin/com/dulkirfabric/events/base') diff --git a/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt b/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt new file mode 100644 index 0000000..1c1ddcd --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt @@ -0,0 +1,25 @@ +package com.dulkirfabric.events.base + +import com.dulkirfabric.DulkirModFabric +import meteordevelopment.orbit.ICancellable + +abstract class CancellableEvent: ICancellable { + + var cancelled: Boolean = 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 { + DulkirModFabric.EVENT_BUS.post(this) + return cancelled + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/events/base/Event.kt b/src/main/kotlin/com/dulkirfabric/events/base/Event.kt new file mode 100644 index 0000000..7671199 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/events/base/Event.kt @@ -0,0 +1,9 @@ +package com.dulkirfabric.events.base + +import com.dulkirfabric.DulkirModFabric + +abstract class Event { + fun post() { + DulkirModFabric.EVENT_BUS.post(this) + } +} \ No newline at end of file -- cgit