Skip to content

Commit

Permalink
fix: use correct pluginMessage channel for discord -> mc
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Feb 26, 2024
1 parent 5f25ef6 commit 7bdeeed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,10 @@ fun handleChatFilters(message: Component, player: Player, audience: Player?) : C
fun handleUrlReplacements(message: Component, player: Player?): Component {
var component = message
component.clickEvent()?.takeIf { it.action() == ClickEvent.Action.OPEN_URL }?.let { clickEvent ->
val (regex, textReplacement) = chatty.config.chat.urlReplacements.firstOrNull { it.regex in clickEvent.value() }?.let { it.regex to it.replacement } ?: return@let
component = component.replaceText(TextReplacementConfig.builder().match(regex.pattern).replacement(textReplacement).build())

val (regex, replacement) = chatty.config.chat.urlReplacements.firstOrNull { it.regex in clickEvent.value() }?.let { it.regex to it.replacement } ?: return@let
val hoverComponent = Component.text(clickEvent.value()).style(Style.style(TextDecoration.UNDERLINED))
component = component.hoverEvent(HoverEventSource.unbox(HoverEvent.showText(hoverComponent)))
component = component.replaceText(TextReplacementConfig.builder().match(regex.pattern).replacement(replacement.hoverEventShowText(hoverComponent)).build())
}

return component.children(component.children().map { handleUrlReplacements(it, player) })
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.mineinabyss.chatty.listeners

import com.mineinabyss.chatty.chatty
import com.mineinabyss.chatty.chattyProxyChannel
import com.mineinabyss.chatty.components.ChannelData
import com.mineinabyss.chatty.discordSrvChannel
import com.mineinabyss.chatty.helpers.defaultChannel
import com.mineinabyss.chatty.helpers.globalChannel
import com.mineinabyss.chatty.helpers.handleChatFilters
Expand Down Expand Up @@ -37,7 +37,7 @@ class DiscordListener {
val simpleMessage = mm.deserialize(message.author.name + ": " + message.contentRaw)
val message = if (chatty.config.chat.formatURLs) handleUrlReplacements(minecraftMessage.toComponent(), null).toComponentDSV() else minecraftMessage
val minecraftMessage = ComponentDSV.textOfChildren(senderName, channelId, message, simpleMessage)
chatty.plugin.server.sendPluginMessage(chatty.plugin, chattyProxyChannel, gson.serialize(minecraftMessage).toByteArray())
chatty.plugin.server.sendPluginMessage(chatty.plugin, discordSrvChannel, gson.serialize(minecraftMessage).toByteArray())
setMinecraftMessage(message)
}

Expand Down

0 comments on commit 7bdeeed

Please sign in to comment.