diff options
Diffstat (limited to 'src/main/kotlin/event')
-rw-r--r-- | src/main/kotlin/event/TickEvent.kt | 6 | ||||
-rw-r--r-- | src/main/kotlin/event/UltraEvent.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/event/UltraNotifierEvents.kt | 5 | ||||
-rw-r--r-- | src/main/kotlin/event/VisibleChatMessageAddedEvent.kt | 17 |
4 files changed, 26 insertions, 4 deletions
diff --git a/src/main/kotlin/event/TickEvent.kt b/src/main/kotlin/event/TickEvent.kt index 8643261..4bd2c6c 100644 --- a/src/main/kotlin/event/TickEvent.kt +++ b/src/main/kotlin/event/TickEvent.kt @@ -4,10 +4,10 @@ package moe.nea.ultranotifier.event import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents //#endif -class TickEvent : UltraEvent() { +class TickEvent : UltraEvent(), UltraEvent.Silent<TickEvent> { - companion object { - init { + companion object : SubscriptionTarget { + override fun init() { //#if FABRIC ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { TickEvent().post() diff --git a/src/main/kotlin/event/UltraEvent.kt b/src/main/kotlin/event/UltraEvent.kt index 4f615c1..80f63fc 100644 --- a/src/main/kotlin/event/UltraEvent.kt +++ b/src/main/kotlin/event/UltraEvent.kt @@ -7,6 +7,8 @@ abstract class UltraEvent : me.bush.eventbus.event.Event() //#endif { + interface Silent<T> where T : Silent<T>, T : UltraEvent + //#if FORGE //$$ override fun isCancelable(): Boolean { //$$ return this.isCancellable() diff --git a/src/main/kotlin/event/UltraNotifierEvents.kt b/src/main/kotlin/event/UltraNotifierEvents.kt index 7190b63..9c1e1ee 100644 --- a/src/main/kotlin/event/UltraNotifierEvents.kt +++ b/src/main/kotlin/event/UltraNotifierEvents.kt @@ -9,9 +9,12 @@ object UltraNotifierEvents { //#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") + if (event !is UltraEvent.Silent<*>) { + UltraNotifier.logger.info("Posting $event") + } eventBus.post(event) return event } diff --git a/src/main/kotlin/event/VisibleChatMessageAddedEvent.kt b/src/main/kotlin/event/VisibleChatMessageAddedEvent.kt new file mode 100644 index 0000000..97d919b --- /dev/null +++ b/src/main/kotlin/event/VisibleChatMessageAddedEvent.kt @@ -0,0 +1,17 @@ +package moe.nea.ultranotifier.event + +import net.minecraft.client.gui.hud.ChatHudLine +import net.minecraft.text.Text + +typealias ChattyHudLine = + ChatHudLine +//#if MC < 1.20 +//#if MC > 1.16 +//$$ <Text> +//#endif +//#endif + + +data class VisibleChatMessageAddedEvent( + val chatLine: ChattyHudLine, +) : UltraEvent() |