diff options
| author | Linnea Gräf <nea@nea.moe> | 2024-05-03 19:34:32 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2024-05-03 19:34:32 +0200 |
| commit | 9ba9c9bf092b5873ab28162e105574d6c994300e (patch) | |
| tree | 4d9b3bbdf4da18819e26fa8e9a4d4d5260ccf4dd /src/main/java/at/hannibal2/skyhanni/features/misc | |
| parent | e210a5849b2c31628489568470580ec0416285e7 (diff) | |
| download | SkyHanni-feat/styledreplace.tar.gz SkyHanni-feat/styledreplace.tar.bz2 SkyHanni-feat/styledreplace.zip | |
Basic styled replacefeat/styledreplace
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/misc')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt index 5edabcbb1..10e25c54c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt @@ -9,12 +9,17 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.mixins.hooks.RenderLivingEntityHelper import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha +import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.intoSpan +import at.hannibal2.skyhanni.utils.ComponentMatcherUtils.replace +import at.hannibal2.skyhanni.utils.ComponentSpan import at.hannibal2.skyhanni.utils.ConditionalUtils.onToggle import at.hannibal2.skyhanni.utils.EntityUtils import at.hannibal2.skyhanni.utils.LorenzUtils import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.util.ChatComponentText import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern class MarkedPlayerManager { companion object { @@ -91,6 +96,20 @@ class MarkedPlayerManager { } return text } + + fun replaceInChat(string: ComponentSpan): ComponentSpan { + if (!config.highlightInChat) return string + + val color = config.chatColor.getChatColor() + var text = string + for (markedPlayer in playerNamesToMark) { + text = text.replace(markedPlayer.toPattern(Pattern.LITERAL)) { + ChatComponentText(color) + .appendSibling(group().intoComponent()) + }.intoSpan() + } + return text + } } @SubscribeEvent |
