summaryrefslogtreecommitdiff
path: root/src/main/kotlin/event
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/event')
-rw-r--r--src/main/kotlin/event/ChatLineAddedEvent.kt7
-rw-r--r--src/main/kotlin/event/UltraEvent.kt37
-rw-r--r--src/main/kotlin/event/UltraNotifierEvents.kt20
-rw-r--r--src/main/kotlin/event/UltraSubscribe.kt8
4 files changed, 72 insertions, 0 deletions
diff --git a/src/main/kotlin/event/ChatLineAddedEvent.kt b/src/main/kotlin/event/ChatLineAddedEvent.kt
new file mode 100644
index 0000000..0460f83
--- /dev/null
+++ b/src/main/kotlin/event/ChatLineAddedEvent.kt
@@ -0,0 +1,7 @@
+package moe.nea.ultranotifier.event
+
+import net.minecraft.text.Text
+
+class ChatLineAddedEvent(val component: Text) : UltraEvent() {
+ val string = component.string
+}
diff --git a/src/main/kotlin/event/UltraEvent.kt b/src/main/kotlin/event/UltraEvent.kt
new file mode 100644
index 0000000..42fa4f2
--- /dev/null
+++ b/src/main/kotlin/event/UltraEvent.kt
@@ -0,0 +1,37 @@
+package moe.nea.ultranotifier.event
+
+abstract class UltraEvent :
+//#if FORGE
+//$$ net.minecraftforge.eventbus.api.Event()
+//#else
+ me.bush.eventbus.event.Event()
+//#endif
+{
+//#if FORGE
+//$$ override fun isCancelable(): Boolean {
+//$$ return this.isCancellable()
+//$$ }
+//$$ fun isCancelled(): Boolean {
+//$$ return isCanceled()
+//$$ }
+//$$ fun setCancelled(value: Boolean) {
+//$$ setCanceled(value)
+//$$ }
+//#else
+ override
+//#endif
+
+ fun isCancellable(): Boolean {
+ return true
+ }
+
+//#if FORGE == 0
+ override
+//#endif
+ fun cancel() {
+ setCancelled(true)
+ }
+
+}
+
+
diff --git a/src/main/kotlin/event/UltraNotifierEvents.kt b/src/main/kotlin/event/UltraNotifierEvents.kt
new file mode 100644
index 0000000..8c8fb13
--- /dev/null
+++ b/src/main/kotlin/event/UltraNotifierEvents.kt
@@ -0,0 +1,20 @@
+package moe.nea.ultranotifier.event
+
+import moe.nea.ultranotifier.UltraNotifier
+
+object UltraNotifierEvents {
+ val eventBus =
+//#if FORGE
+//$$ net.minecraftforge.common.MinecraftForge.EVENT_BUS
+//#else
+ me.bush.eventbus.bus.EventBus { UltraNotifier.logger.warn("EventBus: $it") }
+//#endif
+ @JvmStatic
+ fun <T : UltraEvent> post(event: T): T {
+ UltraNotifier.logger.info("Posting $event")
+ eventBus.post(event)
+ return event
+ }
+}
+
+
diff --git a/src/main/kotlin/event/UltraSubscribe.kt b/src/main/kotlin/event/UltraSubscribe.kt
new file mode 100644
index 0000000..d0b37ef
--- /dev/null
+++ b/src/main/kotlin/event/UltraSubscribe.kt
@@ -0,0 +1,8 @@
+package moe.nea.ultranotifier.event
+
+typealias UltraSubscribe =
+//#if FORGE
+//$$ net.minecraftforge.eventbus.api.SubscribeEvent
+//#else
+ me.bush.eventbus.annotation.EventListener
+//#endif