aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-21 20:12:09 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2024-03-21 20:12:09 +0100
commit505b963af2b27e6f5a2783f27c20ff209628b60b (patch)
treef9fb7a0edb0974c4e0ef0e5cce3449152d6b2315 /src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
parent1d61933a29785f873a04a93f6c32e9570e13dfc6 (diff)
downloadskyhanni-505b963af2b27e6f5a2783f27c20ff209628b60b.tar.gz
skyhanni-505b963af2b27e6f5a2783f27c20ff209628b60b.tar.bz2
skyhanni-505b963af2b27e6f5a2783f27c20ff209628b60b.zip
code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
index bede93187..a937b6f12 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt
@@ -91,9 +91,7 @@ object StringUtils {
return cleanedString.toString()
}
- fun UUID.toDashlessUUID(): String {
- return toString().replace("-", "")
- }
+ fun UUID.toDashlessUUID(): String = toString().replace("-", "")
inline fun <T> Pattern.matchMatcher(text: String, consumer: Matcher.() -> T) =
matcher(text).let { if (it.matches()) consumer(it) else null }
@@ -260,15 +258,9 @@ object StringUtils {
return chatComponent
}
- fun String.getPlayerNameFromChatMessage(): String? {
- val matcher = matchPlayerChatMessage(this) ?: return null
- return matcher.group("username")
- }
+ fun String.getPlayerNameFromChatMessage(): String? = matchPlayerChatMessage(this)?.group("username")
- fun String.getPlayerNameAndRankFromChatMessage(): String? {
- val matcher = matchPlayerChatMessage(this) ?: return null
- return matcher.group("rankedName")
- }
+ fun String.getPlayerNameAndRankFromChatMessage(): String? = matchPlayerChatMessage(this)?.group("rankedName")
private fun matchPlayerChatMessage(string: String): Matcher? {
var username = ""
@@ -304,10 +296,7 @@ object StringUtils {
fun String?.equalsIgnoreColor(string: String?) = this?.let { it.removeColor() == string?.removeColor() } ?: false
- fun String.isRoman(): Boolean {
- return UtilsPatterns.isRomanPattern.matches(this)
- }
- fun isEmpty(message: String): Boolean {
- return message.removeColor().trimWhiteSpaceAndResets().isEmpty()
- }
+ fun String.isRoman(): Boolean = UtilsPatterns.isRomanPattern.matches(this)
+
+ fun isEmpty(message: String): Boolean = message.removeColor().trimWhiteSpaceAndResets().isEmpty()
}