Skip to content

Commit

Permalink
Allow player-message tasks to contain formatted messages
Browse files Browse the repository at this point in the history
  • Loading branch information
4Ply committed Jan 25, 2025
1 parent 362d317 commit 1e6548a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/kotlin/org/trackedout/citadel/PlayerExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ import com.saicone.rtag.RtagItem
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.text.minimessage.MiniMessage
import org.bukkit.Material
import org.bukkit.command.CommandSender
import org.bukkit.entity.HumanEntity
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import org.trackedout.citadel.inventory.DeckId
import org.trackedout.citadel.inventory.intoDungeonItems
import org.trackedout.data.Cards

val debugTag = "debug"

fun Player.sendMiniMessage(message: String) {
val parsed = MiniMessage.miniMessage().deserialize(message)
this.sendMessage(parsed)
}

fun CommandSender.sendGreenMessage(message: String) {
this.sendMessage(Component.text().color(NamedTextColor.GREEN).content(message).build())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ScheduledTaskRunner(
"message-player" -> {
val targetPlayer = plugin.server.worlds.find { it.name == "world" }?.players?.find { it.name == task.targetPlayer }
if (targetPlayer != null) {
task.arguments?.forEach(targetPlayer::sendMessage)
task.arguments?.forEach(targetPlayer::sendMiniMessage)
} else {
val message = "Task type is '${task.type}' which targets a player, but the player was not found"
plugin.logger.warning(message)
Expand Down

0 comments on commit 1e6548a

Please sign in to comment.