[enhancement] Added sound to FriendHighlight. (#1600)

This commit is contained in:
FriedrichM 2020-11-17 19:41:58 +01:00 committed by GitHub
parent a971ff2751
commit 72cd9d9767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -9,6 +9,8 @@ import me.zeroeightsix.kami.util.color.ColorTextFormatting
import me.zeroeightsix.kami.util.color.ColorTextFormatting.ColourCode
import me.zeroeightsix.kami.util.event.listener
import me.zeroeightsix.kami.util.text.MessageSendHelper
import net.minecraft.client.audio.PositionedSoundRecord
import net.minecraft.init.SoundEvents
import net.minecraft.util.text.TextComponentString
import net.minecraft.util.text.TextFormatting
import net.minecraftforge.client.event.ClientChatReceivedEvent
@ -22,6 +24,7 @@ import net.minecraftforge.client.event.ClientChatReceivedEvent
object FriendHighlight : Module() {
private val bold = register(Settings.b("Bold", true))
private val colour = register(Settings.e<ColourCode>("Color", ColourCode.GRAY))
private val sound = register(Settings.b("Sound", true))
private val regex1 = "<(.*?)>".toRegex()
private val regex2 = "[<>]".toRegex()
@ -38,6 +41,7 @@ object FriendHighlight : Module() {
if (playerName == null || !FriendManager.isFriend(playerName)) return@listener
val modified = it.message.formattedText.replaceFirst(playerName, getReplacement(playerName))
val textComponent = TextComponentString(modified)
if (sound.value) mc.getSoundHandler().playSound(PositionedSoundRecord.getRecord(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0f, 1.0f))
it.message = textComponent
}