From c9c25b61560e6fb4e1ba2dfb1d5cc61b0ec9ddab Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 30 Oct 2024 16:35:19 +0100 Subject: Add warning for missing REI --- src/main/kotlin/util/textutil.kt | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin/util/textutil.kt') diff --git a/src/main/kotlin/util/textutil.kt b/src/main/kotlin/util/textutil.kt index 252f708..a6a7e87 100644 --- a/src/main/kotlin/util/textutil.kt +++ b/src/main/kotlin/util/textutil.kt @@ -1,5 +1,6 @@ package moe.nea.firmament.util +import net.minecraft.text.ClickEvent import net.minecraft.text.MutableText import net.minecraft.text.PlainTextContent import net.minecraft.text.Text @@ -119,7 +120,30 @@ fun Text.iterator(): Sequence { fun Text.allSiblings(): List = listOf(this) + siblings.flatMap { it.allSiblings() } -fun MutableText.withColor(formatting: Formatting) = this.styled { it.withColor(formatting).withItalic(false) } +fun MutableText.withColor(formatting: Formatting): MutableText = this.styled { + it.withColor(formatting) + .withItalic(false) + .withBold(false) +} + +fun MutableText.blue() = withColor(Formatting.BLUE) +fun MutableText.aqua() = withColor(Formatting.AQUA) +fun MutableText.lime() = withColor(Formatting.GREEN) +fun MutableText.darkGreen() = withColor(Formatting.DARK_GREEN) +fun MutableText.yellow() = withColor(Formatting.YELLOW) +fun MutableText.grey() = withColor(Formatting.GRAY) +fun MutableText.red() = withColor(Formatting.RED) +fun MutableText.white() = withColor(Formatting.WHITE) +fun MutableText.bold(): MutableText = styled { it.withBold(true) } + + +fun MutableText.clickCommand(command: String): MutableText { + require(command.startsWith("/")) + return this.styled { + it.withClickEvent(ClickEvent(ClickEvent.Action.RUN_COMMAND, + "/firm disablereiwarning")) + } +} fun Text.transformEachRecursively(function: (Text) -> Text): Text { val c = this.content -- cgit