diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-05-12 00:53:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-12 00:53:09 +0200 |
commit | 3bb4b9b9826fadd8df3507ea86b6196b6487b981 (patch) | |
tree | 9876124908f9d0a9656b1ab9690a3c2211bc9435 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | b391c5d5c660436112da31d69e025bd6f4622a02 (diff) | |
download | skyhanni-3bb4b9b9826fadd8df3507ea86b6196b6487b981.tar.gz skyhanni-3bb4b9b9826fadd8df3507ea86b6196b6487b981.tar.bz2 skyhanni-3bb4b9b9826fadd8df3507ea86b6196b6487b981.zip |
Feature: Blaze Slayer Fire Pillar Display (#1766)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index c048004f2..4e5bce010 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -106,6 +106,9 @@ object StringUtils { inline fun <T> Pattern.findMatcher(text: String, consumer: Matcher.() -> T) = matcher(text).let { if (it.find()) consumer(it) else null } + inline fun <T> Sequence<String>.matchFirst(pattern: Pattern, consumer: Matcher.() -> T): T? = + toList().matchFirst(pattern, consumer) + inline fun <T> List<String>.matchFirst(pattern: Pattern, consumer: Matcher.() -> T): T? { for (line in this) { pattern.matcher(line).let { if (it.matches()) return consumer(it) } @@ -309,8 +312,9 @@ object StringUtils { fun String.convertToFormatted(): String = this.replace("&&", "ยง") - fun Pattern.matches(string: String?) = string?.let { matcher(it).matches() } ?: false - fun Pattern.anyMatches(list: List<String>?) = list?.any { this.matches(it) } ?: false + fun Pattern.matches(string: String?): Boolean = string?.let { matcher(it).matches() } ?: false + fun Pattern.anyMatches(list: List<String>?): Boolean = list?.any { this.matches(it) } ?: false + fun Pattern.anyMatches(list: Sequence<String>?): Boolean = anyMatches(list?.toList()) fun Pattern.find(string: String?) = string?.let { matcher(it).find() } ?: false @@ -331,7 +335,6 @@ object StringUtils { return replaceIfNeeded(original, ChatComponentText(newText)) } - private val colorMap = EnumChatFormatting.entries.associateBy { it.toString()[1] } fun enumChatFormattingByCode(char: Char): EnumChatFormatting? { return colorMap[char] @@ -395,7 +398,6 @@ object StringUtils { } } - fun <T : IChatComponent> replaceIfNeeded( original: T, newText: T, @@ -435,7 +437,7 @@ object StringUtils { private fun IChatComponent.findAllEvents( clickEvents: MutableList<ClickEvent>, - hoverEvents: MutableList<HoverEvent> + hoverEvents: MutableList<HoverEvent>, ) { siblings.forEach { it.findAllEvents(clickEvents, hoverEvents) } |