Make chat events use fabric events
[no changelog]
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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("&", "§"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user