Skip to content

Commit

Permalink
Resolve review requests
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Dec 5, 2023
1 parent 6bb8bc8 commit 5f5edbc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import com.mineinabyss.chatty.components.ChannelType
import com.mineinabyss.chatty.components.SpyOnChannels
import com.mineinabyss.chatty.queries.SpyingPlayers
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
import com.mineinabyss.idofront.serialization.ColorSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import net.kyori.adventure.audience.Audience
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.format.TextColor
import org.bukkit.Bukkit
import org.bukkit.Color
import org.bukkit.entity.Player

@Serializable
Expand All @@ -23,14 +25,14 @@ data class ChattyChannel(
val isDefaultChannel: Boolean = false,
val isStaffChannel: Boolean = false,
val format: String = "",
@SerialName("messageColor") val _messageColor: String = "white",
@Serializable(with=ColorSerializer::class)
@SerialName("messageColor") val _messageColor: Color = Color.WHITE,
val channelRadius: Int = 0,
val channelAliases: List<String> = listOf(),
) {
val key by lazy { chatty.config.channels.entries.first { it.value == this }.key }
val messageColor: TextColor
get() = TextColor.fromHexString(_messageColor) ?: NamedTextColor.NAMES.value(_messageColor)
?: NamedTextColor.WHITE
get() = TextColor.color(_messageColor.asRGB())


fun getAudience(player: Player): Collection<Audience> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import java.util.*
@SerialName("chatty:chatty_data")
data class ChannelData(
val channelId: String = getDefaultChat().key,
@SerialName("lastChannelUsed")
val lastChannelUsedId: String = channelId,
val disablePingSound: Boolean = false,
val pingSound: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class ChatListener : Listener {
val pingedPlayer = originalMessage().serialize().checkForPlayerPings(channelId)
if (pingedPlayer != null && pingedPlayer != player && pingedPlayer in viewers()) {
viewers() -= setOf(pingedPlayer, player)
val pingedChannelData = pingedPlayer.toGearyOrNull()?.get<ChannelData>()
if (pingedChannelData != null)
pingedPlayer.toGearyOrNull()?.get<ChannelData>()?.let { pingedChannelData ->
message().handlePlayerPings(player, pingedPlayer, pingedChannelData)
}
}

if (channel.proxy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ChattyProxyListener : PluginMessageListener {
ChannelType.RADIUS -> canSpy
ChannelType.PERMISSION -> onlinePlayers.filter { it.hasPermission(channel.permission) || it in canSpy }
ChannelType.PRIVATE -> onlinePlayers.filter {
it.toGeary().get<ChannelData>()?.channel == channel || it in canSpy
it.toGeary().get<ChannelData>()?.withChannelVerified()?.channel == channel || it in canSpy
}
}.forEach { it.sendMessage(proxyMessage.miniMsg()) }
}
Expand Down Expand Up @@ -83,14 +83,14 @@ class ChattyProxyListener : PluginMessageListener {
DiscordSRV.error("Couldn't deliver chat message as webhook because the bot lacks the \"Manage Webhooks\" permission.")

else -> {
val discordMessage = proxyMessage.replaceFirst(channelFormat, "")
.apply { PlaceholderUtil.replacePlaceholdersToDiscord(this) }
.apply { if (!reserializer) MessageUtil.strip(this) }
.apply {
if (translateMentions) DiscordUtil.convertMentionsFromNames(
this,
DiscordSRV.getPlugin().mainGuild
)
val discordMessage = proxyMessage
.replaceFirst(channelFormat, "")
.run { PlaceholderUtil.replacePlaceholdersToDiscord(this) }
.run { if (!reserializer) MessageUtil.strip(this) else this }
.run {
if (translateMentions)
DiscordUtil.convertMentionsFromNames(this,DiscordSRV.getPlugin().mainGuild)
else this
}

val whUsername = DiscordSRV.config().getString("Experiment_WebhookChatMessageUsernameFormat")
Expand Down

0 comments on commit 5f5edbc

Please sign in to comment.