diff options
author | nea <nea@nea.moe> | 2023-09-04 20:22:51 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-09-04 20:22:51 +0200 |
commit | d202ef5439a180efecc27ab4695b1a12febb041f (patch) | |
tree | 959ac68db802d562dee2d92aecbb3741dbcce3b6 /src/main/kotlin/moe/nea/firmament/features | |
parent | ee5591684dc6bcdea6c44a62806d537bbb7e0cee (diff) | |
download | firmament-d202ef5439a180efecc27ab4695b1a12febb041f.tar.gz firmament-d202ef5439a180efecc27ab4695b1a12febb041f.tar.bz2 firmament-d202ef5439a180efecc27ab4695b1a12febb041f.zip |
Make chat events use fabric events
[no changelog]
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/features')
4 files changed, 38 insertions, 5 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt index 91f5e03..781237e 100644 --- a/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt +++ b/src/main/kotlin/moe/nea/firmament/features/FeatureManager.kt @@ -12,6 +12,7 @@ import moe.nea.firmament.Firmament import moe.nea.firmament.features.chat.ChatLinks import moe.nea.firmament.features.debug.DebugView import moe.nea.firmament.features.debug.DeveloperFeatures +import moe.nea.firmament.features.debug.MinorTrolling import moe.nea.firmament.features.fixes.Fixes import moe.nea.firmament.features.inventory.CraftingOverlay import moe.nea.firmament.features.inventory.PriceData @@ -41,6 +42,7 @@ object FeatureManager : DataHolder<FeatureManager.Config>(serializer(), "feature fun autoload() { synchronized(this) { if (hasAutoloaded) return + loadFeature(MinorTrolling) loadFeature(FairySouls) // TODO: loadFeature(FishingWarning) loadFeature(SlotLocking) diff --git a/src/main/kotlin/moe/nea/firmament/features/chat/ChatLinks.kt b/src/main/kotlin/moe/nea/firmament/features/chat/ChatLinks.kt index 1ce5a1b..fb3c0c2 100644 --- a/src/main/kotlin/moe/nea/firmament/features/chat/ChatLinks.kt +++ b/src/main/kotlin/moe/nea/firmament/features/chat/ChatLinks.kt @@ -26,7 +26,7 @@ import net.minecraft.text.Text import net.minecraft.util.Formatting import net.minecraft.util.Identifier import moe.nea.firmament.Firmament -import moe.nea.firmament.events.ClientChatLineReceivedEvent +import moe.nea.firmament.events.ModifyChatEvent import moe.nea.firmament.events.ScreenRenderPostEvent import moe.nea.firmament.features.FirmamentFeature import moe.nea.firmament.gui.config.ManagedConfig @@ -98,9 +98,9 @@ object ChatLinks : FirmamentFeature { @OptIn(ExperimentalCoroutinesApi::class) override fun onLoad() { - ClientChatLineReceivedEvent.subscribe { + ModifyChatEvent.subscribe { if (TConfig.enableLinks) - it.replaceWith = it.text.transformEachRecursively { child -> + it.replaceWith = it.replaceWith.transformEachRecursively { child -> val text = child.string if ("://" !in text) return@transformEachRecursively child val s = Text.empty().setStyle(child.style) diff --git a/src/main/kotlin/moe/nea/firmament/features/debug/MinorTrolling.kt b/src/main/kotlin/moe/nea/firmament/features/debug/MinorTrolling.kt new file mode 100644 index 0000000..95c77ab --- /dev/null +++ b/src/main/kotlin/moe/nea/firmament/features/debug/MinorTrolling.kt @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.features.debug + +import moe.nea.firmament.events.ModifyChatEvent +import moe.nea.firmament.features.FirmamentFeature +import net.minecraft.text.Text + + +// In memorian Dulkir +object MinorTrolling : FirmamentFeature { + override val identifier: String + get() = "minor-trolling" + + val trollers = listOf("nea89o", "lrg89") + val t = "From(?: \\[[^\\]]+])? ([^:]+): (.*)".toRegex() + + override fun onLoad() { + ModifyChatEvent.subscribe { + val m = t.matchEntire(it.unformattedString) ?: return@subscribe + val (_, name, text) = m.groupValues + if (name !in trollers) return@subscribe + if (!text.startsWith("c:")) return@subscribe + it.replaceWith = Text.literal(text.substring(2).replace("&", "§")) + } + } +} diff --git a/src/main/kotlin/moe/nea/firmament/features/world/FairySouls.kt b/src/main/kotlin/moe/nea/firmament/features/world/FairySouls.kt index c1ccfc4..462325e 100644 --- a/src/main/kotlin/moe/nea/firmament/features/world/FairySouls.kt +++ b/src/main/kotlin/moe/nea/firmament/features/world/FairySouls.kt @@ -17,7 +17,7 @@ import net.minecraft.client.render.VertexFormat import net.minecraft.client.render.VertexFormats import net.minecraft.text.Text import net.minecraft.util.math.Vec3d -import moe.nea.firmament.events.ServerChatLineReceivedEvent +import moe.nea.firmament.events.AllowChatEvent import moe.nea.firmament.events.SkyblockServerUpdateEvent import moe.nea.firmament.events.WorldRenderLastEvent import moe.nea.firmament.features.FirmamentFeature @@ -125,7 +125,7 @@ object FairySouls : FirmamentFeature { updateWorldSouls() updateMissingSouls() } - ServerChatLineReceivedEvent.subscribe { + AllowChatEvent.subscribe { when (it.text.unformattedString) { "You have already found that Fairy Soul!" -> { markNearestSoul() |