diff options
author | nea <nea@nea.moe> | 2023-05-16 01:23:43 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-16 01:23:43 +0200 |
commit | ead6762eb1c005914b05f9d3c29f334989c67513 (patch) | |
tree | cd1409756be2bc4a93195c31d432fef053afe002 /src/main/kotlin/moe/nea/notenoughupdates/events | |
parent | 96c546cc73880a7c502c17aadda6ca84c847692d (diff) | |
download | firmament-ead6762eb1c005914b05f9d3c29f334989c67513.tar.gz firmament-ead6762eb1c005914b05f9d3c29f334989c67513.tar.bz2 firmament-ead6762eb1c005914b05f9d3c29f334989c67513.zip |
Replace references to NEU with Firmament
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/events')
8 files changed, 0 insertions, 146 deletions
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<SomeEvent>() - * } - * ``` - */ -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<T : NEUEvent> { - data class Handler<T>(val invocation: (T) -> Unit, val receivesCancelled: Boolean) - - private val toHandle: MutableList<Handler<T>> = 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<ParticleSpawnEvent>() -} 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<ScreenOpenEvent>() -} 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<ServerChatLineReceivedEvent>() - - 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<SkyblockServerUpdateEvent>() -} 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<WorldReadyEvent>() -} 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<WorldRenderLastEvent>() -} |