From 505b963af2b27e6f5a2783f27c20ff209628b60b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:12:09 +0100 Subject: code cleanup --- .../at/hannibal2/skyhanni/utils/StringUtils.kt | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'src/main/java') 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 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() } -- cgit