diff options
Diffstat (limited to 'src/main')
4 files changed, 59 insertions, 3 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index ffcf85f..d4be8b0 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -8,6 +8,7 @@ import com.dulkirfabric.events.chat.ModifyCommandEvent import com.dulkirfabric.events.chat.OverlayReceivedEvent import com.dulkirfabric.features.* import com.dulkirfabric.features.chat.AbiPhoneDND +import com.dulkirfabric.features.chat.BridgeBotFormatter import com.dulkirfabric.util.TablistUtils import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents @@ -66,6 +67,7 @@ object Registrations { EVENT_BUS.subscribe(CullExplosionParticles) EVENT_BUS.subscribe(CooldownDisplays) EVENT_BUS.subscribe(ArachneFeatures) + EVENT_BUS.subscribe(BridgeBotFormatter) } fun registerEvents() { diff --git a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt index 2795668..99eec24 100644 --- a/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt +++ b/src/main/kotlin/com/dulkirfabric/config/DulkirConfig.kt @@ -219,6 +219,21 @@ class DulkirConfig { .build() ) + val bridge = builder.getOrCreateCategory(Text.literal("Bridge Features")) + + bridge.addEntry( + entryBuilder.mkToggle(Text.literal("Format Bridge Messages"), configOptions::bridgeFormatter) + ) + bridge.addEntry( + entryBuilder.mkStringField(Text.literal("Bridge Bot IGN"), configOptions::bridgeBotName) + ) + bridge.addEntry( + entryBuilder.startColorField(Text.literal("Bridge User Color"), configOptions.bridgeNameColor) + .setDefaultValue(Formatting.GOLD.colorValue!!) + .setSaveConsumer { newValue -> configOptions.bridgeNameColor = newValue } + .build() + ) + builder.transparentBackground() screen = builder.build() } @@ -246,7 +261,10 @@ class DulkirConfig { var duraCooldown: Boolean = false, var alarmTimeout: Int = 300, var arachneKeeperWaypoints: Boolean = false, - var arachneSpawnTimer: Boolean = false + var arachneSpawnTimer: Boolean = false, + var bridgeFormatter: Boolean = false, + var bridgeBotName: String = "Dilkur", + var bridgeNameColor: Int = Formatting.GOLD.colorValue!! ) @Serializable diff --git a/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt b/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt new file mode 100644 index 0000000..f956791 --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/chat/BridgeBotFormatter.kt @@ -0,0 +1,35 @@ +package com.dulkirfabric.features.chat + +import com.dulkirfabric.config.DulkirConfig +import com.dulkirfabric.events.chat.ChatReceivedEvent +import com.dulkirfabric.util.TextUtils +import com.dulkirfabric.util.Utils +import meteordevelopment.orbit.EventHandler +import net.minecraft.text.Style +import net.minecraft.text.Text +import net.minecraft.util.Formatting + +object BridgeBotFormatter { + private val bridgeRegex: Regex = "^(§2Guild|§3Officer) > (?:\\S+ )?([\\w§]{3,18})(?: §[a-z0-9][[A-Z]+])?§f: ([^>]+)(?: >| »|:) (.+)".toRegex() + + @EventHandler + fun onChat(event: ChatReceivedEvent) { + if (!DulkirConfig.configOptions.bridgeFormatter) return + + val message = event.message.string + if (bridgeRegex matches message) { + val matchResult = bridgeRegex.find(message) + val (prefix, name, playerName) = matchResult!!.destructured + if (TextUtils.stripColorCodes(name).equals(DulkirConfig.configOptions.bridgeBotName, ignoreCase = true)) { + val newPrefix = if (prefix == "§2Guild") "§2Bridge" else "§3Bridge" + event.message.siblings[0] = Text.literal( + "$newPrefix > " + ).append(Text.literal(playerName).setStyle(Style.EMPTY.withColor(DulkirConfig.configOptions.bridgeNameColor))) + .append(": ") + event.message.siblings[1] = Text.literal( + event.message.siblings[1].string.replace("$playerName > ", "") + ).setStyle(event.message.siblings[1].style) + } + } + } +}
\ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 3f6321d..c045783 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -16,7 +16,7 @@ }, "license": "MPL-2.0", "icon": "assets/dulkirmod-fabric/icon.png", - "environment": "*", + "environment": "client", "entrypoints": { "main": [ { @@ -47,5 +47,6 @@ "Mod Menu": "https://modrinth.com/mod/modmenu", "Puzzle": "https://www.midnightdust.eu/", "Starlight": "https://www.curseforge.com/minecraft/mc-mods/starlight" - } + }, + "accessWidener" : "dulkirmod.accesswidener" }
\ No newline at end of file |