Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Change return type of MiniMessageHighlighter::highlight to `Compone…
Browse files Browse the repository at this point in the history
…nt` to prevent possible future cast errors
  • Loading branch information
ashli-side-account committed Mar 23, 2024
1 parent ac6c4b0 commit 4184483
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.homchom.recode.ui.text

import io.github.homchom.recode.util.std.interpolate
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.ComponentLike
import net.kyori.adventure.text.format.TextDecoration
import net.kyori.adventure.text.minimessage.Context
import net.kyori.adventure.text.minimessage.MiniMessage
Expand Down Expand Up @@ -59,7 +58,7 @@ class MiniMessageHighlighter(private val standardTags: TagResolver) {
* - All other valid tags are treated as "literals" and colored gray.
*/
@Suppress("UnstableApiUsage") // TODO: open issue at adventure github
fun highlight(input: String): ComponentLike {
fun highlight(input: String): Component {
// handle the special case of inputs with <reset> parser directives
// TODO: determine if there is a better way to do this
val splitByResets = input.split("<reset>")
Expand All @@ -69,7 +68,7 @@ class MiniMessageHighlighter(private val standardTags: TagResolver) {
literal("<reset>")
}
append(highlight(splitByResets.last()))
}
}.asComponent()

fun TagNode.input() = with(token()) { input.substring(startIndex(), endIndex()) }
fun ValueNode.input() = with(token()) { input.substring(startIndex(), endIndex()) }
Expand Down

0 comments on commit 4184483

Please sign in to comment.