diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-04-25 10:52:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 10:52:05 +0200 |
commit | 64c502ef79a8fd309a1a4654285a77632e02068c (patch) | |
tree | 2e3ea7739468bc301f16ebc48bd797d3d1fc2b56 /src/main/java/at/hannibal2/skyhanni/config/commands | |
parent | 2c4ce945f83db14fd832d9a8921dac4ff8ec8628 (diff) | |
download | skyhanni-64c502ef79a8fd309a1a4654285a77632e02068c.tar.gz skyhanni-64c502ef79a8fd309a1a4654285a77632e02068c.tar.bz2 skyhanni-64c502ef79a8fd309a1a4654285a77632e02068c.zip |
Improvelement: Cleanup /shcommand hover description (#1531)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config/commands')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt | 26 |
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()) } } |