From ead6762eb1c005914b05f9d3c29f334989c67513 Mon Sep 17 00:00:00 2001 From: nea Date: Tue, 16 May 2023 01:23:43 +0200 Subject: Replace references to NEU with Firmament --- .../moe/nea/notenoughupdates/events/NEUEvent.kt | 36 --------------------- .../moe/nea/notenoughupdates/events/NEUEventBus.kt | 37 ---------------------- .../notenoughupdates/events/ParticleSpawnEvent.kt | 13 -------- .../nea/notenoughupdates/events/ScreenOpenEvent.kt | 7 ---- .../events/ServerChatLineReceivedEvent.kt | 13 -------- .../events/SkyblockServerUpdateEvent.kt | 13 -------- .../nea/notenoughupdates/events/WorldReadyEvent.kt | 5 --- .../events/WorldRenderLastEvent.kt | 22 ------------- 8 files changed, 146 deletions(-) delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/ParticleSpawnEvent.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/ScreenOpenEvent.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/WorldReadyEvent.kt delete mode 100644 src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt (limited to 'src/main/kotlin/moe/nea/notenoughupdates/events') diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt deleted file mode 100644 index 81dc6fc..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt +++ /dev/null @@ -1,36 +0,0 @@ -package moe.nea.notenoughupdates.events - -/** - * An event that can be fired by a [NEUEventBus]. - * - * Typically, that event bus is implemented as a companion object - * - * ``` - * class SomeEvent : NEUEvent() { - * companion object : NEUEventBus() - * } - * ``` - */ -abstract class NEUEvent { - /** - * A [NEUEvent] that can be [cancelled] - */ - abstract class Cancellable : NEUEvent() { - /** - * Cancels this is event. - * - * @see cancelled - */ - fun cancel() { - cancelled = true - } - - /** - * Whether this event is cancelled. - * - * Cancelled events will bypass handlers unless otherwise specified and will prevent the action that this - * event was originally fired for. - */ - var cancelled: Boolean = false - } -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt deleted file mode 100644 index 7eb0ecd..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt +++ /dev/null @@ -1,37 +0,0 @@ -package moe.nea.notenoughupdates.events - -import java.util.concurrent.CopyOnWriteArrayList -import moe.nea.notenoughupdates.NotEnoughUpdates - -/** - * A pubsub event bus. - * - * [subscribe] to events [publish]ed on this event bus. - * Subscriptions may not necessarily be delivered in the order or registering. - */ -open class NEUEventBus { - data class Handler(val invocation: (T) -> Unit, val receivesCancelled: Boolean) - - private val toHandle: MutableList> = CopyOnWriteArrayList() - fun subscribe(handle: (T) -> Unit) { - subscribe(handle, false) - } - - fun subscribe(handle: (T) -> Unit, receivesCancelled: Boolean) { - toHandle.add(Handler(handle, receivesCancelled)) - } - - fun publish(event: T): T { - for (function in toHandle) { - if (function.receivesCancelled || event !is NEUEvent.Cancellable || !event.cancelled) { - try { - function.invocation(event) - } catch (e: Exception) { - NotEnoughUpdates.logger.error("Caught exception during processing event $event", e) - } - } - } - return event - } - -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/ParticleSpawnEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/ParticleSpawnEvent.kt deleted file mode 100644 index 23c67a0..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/ParticleSpawnEvent.kt +++ /dev/null @@ -1,13 +0,0 @@ -package moe.nea.notenoughupdates.events - -import net.minecraft.particle.ParticleEffect -import net.minecraft.util.math.Vec3d - -data class ParticleSpawnEvent( - val particleEffect: ParticleEffect, - val position: Vec3d, - val offset: Vec3d, - val longDistance: Boolean, -) : NEUEvent() { - companion object : NEUEventBus() -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/ScreenOpenEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/ScreenOpenEvent.kt deleted file mode 100644 index 793f066..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/ScreenOpenEvent.kt +++ /dev/null @@ -1,7 +0,0 @@ -package moe.nea.notenoughupdates.events - -import net.minecraft.client.gui.screen.Screen - -data class ScreenOpenEvent(val old: Screen?, val new: Screen?) : NEUEvent.Cancellable() { - companion object : NEUEventBus() -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt deleted file mode 100644 index 681ec6c..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt +++ /dev/null @@ -1,13 +0,0 @@ -package moe.nea.notenoughupdates.events - -import net.minecraft.text.Text -import moe.nea.notenoughupdates.util.unformattedString - -/** - * This event gets published whenever the client receives a chat message from the server. - */ -data class ServerChatLineReceivedEvent(val text: Text) : NEUEvent.Cancellable() { - companion object : NEUEventBus() - - val unformattedString = text.unformattedString -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt deleted file mode 100644 index 541b4c6..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt +++ /dev/null @@ -1,13 +0,0 @@ -package moe.nea.notenoughupdates.events - -import moe.nea.notenoughupdates.util.Locraw - -/** - * This event gets published whenever `/locraw` is queried and HyPixel returns a location different to the old one. - * - * **N.B.:** This event may get fired multiple times while on the server (for example, first to null, then to the - * correct location). - */ -data class SkyblockServerUpdateEvent(val oldLocraw: Locraw?, val newLocraw: Locraw?) : NEUEvent() { - companion object : NEUEventBus() -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldReadyEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/WorldReadyEvent.kt deleted file mode 100644 index 5f305f1..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldReadyEvent.kt +++ /dev/null @@ -1,5 +0,0 @@ -package moe.nea.notenoughupdates.events - -class WorldReadyEvent : NEUEvent() { - companion object : NEUEventBus() -} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt deleted file mode 100644 index 60b7e06..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt +++ /dev/null @@ -1,22 +0,0 @@ -package moe.nea.notenoughupdates.events - -import org.joml.Matrix4f -import net.minecraft.client.render.Camera -import net.minecraft.client.render.GameRenderer -import net.minecraft.client.render.LightmapTextureManager -import net.minecraft.client.util.math.MatrixStack - -/** - * This event is called after all world rendering is done, but before any GUI rendering (including hand) has been done. - */ -data class WorldRenderLastEvent( - val matrices: MatrixStack, - val tickDelta: Float, - val renderBlockOutline: Boolean, - val camera: Camera, - val gameRenderer: GameRenderer, - val lightmapTextureManager: LightmapTextureManager, - val positionMatrix: Matrix4f, -) : NEUEvent() { - companion object : NEUEventBus() -} -- cgit