aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/events/base
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-09 16:55:24 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-09 16:55:24 -0500
commitc0eb625a9b937bcb9256e98afb80d32443daa795 (patch)
tree3b1056bb17a50faabce65ee62a763050bb636741 /src/main/kotlin/com/dulkirfabric/events/base
parent88a2da60ac3a074dd93fa13f262775b05573548f (diff)
downloadDulkirMod-Fabric-c0eb625a9b937bcb9256e98afb80d32443daa795.tar.gz
DulkirMod-Fabric-c0eb625a9b937bcb9256e98afb80d32443daa795.tar.bz2
DulkirMod-Fabric-c0eb625a9b937bcb9256e98afb80d32443daa795.zip
1.20 refactor
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/events/base')
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/base/CancellableEvent.kt25
-rw-r--r--src/main/kotlin/com/dulkirfabric/events/base/Event.kt9
2 files changed, 34 insertions, 0 deletions
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