aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt7
2 files changed, 18 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
index 8309a8f86..d1a9922cb 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzColor.kt
@@ -25,6 +25,17 @@ enum class LorenzColor(val chatColorCode: Char, private val color: Color, privat
CHROMA('Z', Color(0, 0, 0, 0), "§ZChroma") // If chroma, go transparent instead of color code.
;
+ val next by lazy {
+ when (this) {
+ WHITE -> BLACK
+ CHROMA -> BLACK
+ else -> {
+ val index = entries.indexOf(this)
+ entries[index + 1]
+ }
+ }
+ }
+
fun getChatColor(): String = "§$chatColorCode"
fun toColor(): Color = color
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt
index f12ecdef6..927b08d54 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/RegexUtils.kt
@@ -49,4 +49,11 @@ object RegexUtils {
fun Matcher.groupOrNull(groupName: String): String? = runCatching { this.group(groupName) }.getOrNull()
fun Matcher.hasGroup(groupName: String): Boolean = groupOrNull(groupName) != null
+
+ fun List<String>.indexOfFirstMatch(pattern: Pattern): Int? {
+ for ((index, line) in this.withIndex()) {
+ pattern.matcher(line).let { if (it.matches()) return index }
+ }
+ return null
+ }
}