diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/util/Utils.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/util/Utils.kt index 9566b875..53de3471 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/util/Utils.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/util/Utils.kt @@ -82,3 +82,11 @@ fun Collection.valueOf(value: String): E { fun Executor.supplyAsync(block: Supplier): CompletableFuture { return CompletableFuture.supplyAsync(block, this) } + +fun String.limit(limit: Int = 40, replacer: String = "..."): String { + if (length <= limit) { + return this + } + + return substring(0, limit) + replacer +}