aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
index 36494c359..6212c35b0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -75,6 +75,7 @@ import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.SoundUtils
+import at.hannibal2.skyhanni.utils.StringUtils.splitLines
import at.hannibal2.skyhanni.utils.TabListData
import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGui
import net.minecraft.command.ICommandSender
@@ -528,11 +529,11 @@ object Commands {
val hoverText = buildList {
add("§e/$name")
if (command.description.isNotEmpty()) {
- add(" §7${command.description}")
+ addDescription(command.description)
}
add("")
add("$color${category.categoryName}")
- add(" §7${category.description}")
+ addDescription(category.description)
}
val commandInfo = ChatUtils.createHoverableChat("$color/$name", hoverText, "/$name", false)
@@ -544,6 +545,21 @@ object Commands {
ChatUtils.multiComponentMessage(components)
}
+ private fun MutableList<String>.addDescription(description: String) {
+ val lines = description.splitLines(200).removeSuffix("§r").replace("§r", "§7").addOptionalDot()
+ for (line in lines.split("\n")) {
+ add(" §7${line}")
+ }
+ }
+
+ private fun String.addOptionalDot(): String {
+ if (endsWith(".")) return this
+ if (endsWith("?")) return this
+ if (endsWith("!")) return this
+
+ return "$this."
+ }
+
@JvmStatic
fun openFortuneGuide() {
if (!LorenzUtils.inSkyBlock) {
@@ -588,7 +604,11 @@ object Commands {
name,
createCommand(function),
object : SimpleCommand.TabCompleteRunnable {
- override fun tabComplete(sender: ICommandSender?, args: Array<String>?, pos: BlockPos?): List<String> {
+ override fun tabComplete(
+ sender: ICommandSender?,
+ args: Array<String>?,
+ pos: BlockPos?,
+ ): List<String> {
return autoComplete(args ?: emptyArray())
}
}