diff options
| author | Brady <brady@thatgravyboat.tech> | 2024-05-26 10:44:08 -0230 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-26 15:14:08 +0200 |
| commit | ea2cb47c07628abeace3b2d4ac4b3f16b88e382a (patch) | |
| tree | d4b2064cd91ee6323213a89342e7763172a186e2 /src/main/java/at/hannibal2/skyhanni/config | |
| parent | f67af16eacb6cdf3598183d473f072d123ef8a25 (diff) | |
| download | skyhanni-ea2cb47c07628abeace3b2d4ac4b3f16b88e382a.tar.gz skyhanni-ea2cb47c07628abeace3b2d4ac4b3f16b88e382a.tar.bz2 skyhanni-ea2cb47c07628abeace3b2d4ac4b3f16b88e382a.zip | |
Improvement: Cleanup help command (#1720)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
| -rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt | 63 |
1 files changed, 2 insertions, 61 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 ddadb8177..d0fd99dd0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHel import at.hannibal2.skyhanni.features.chat.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil +import at.hannibal2.skyhanni.features.commands.HelpCommand import at.hannibal2.skyhanni.features.commands.PartyChatCommands import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.commands.WikiManager @@ -80,16 +81,11 @@ 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.chat.ChatClickActionManager -import at.hannibal2.skyhanni.utils.chat.Text -import at.hannibal2.skyhanni.utils.chat.Text.hover -import at.hannibal2.skyhanni.utils.chat.Text.suggest import at.hannibal2.skyhanni.utils.repopatterns.RepoPatternGui import net.minecraft.command.ICommandSender import net.minecraft.util.BlockPos -import net.minecraft.util.ChatComponentText import net.minecraftforge.client.ClientCommandHandler object Commands { @@ -156,7 +152,7 @@ object Commands { registerCommand("sh", "Opens the main SkyHanni config", openMainMenu) registerCommand("skyhanni", "Opens the main SkyHanni config", openMainMenu) registerCommand("ff", "Opens the Farming Fortune Guide") { openFortuneGuide() } - registerCommand("shcommands", "Shows this list") { commandHelp(it) } + registerCommand("shcommands", "Shows this list") { HelpCommand.onCommand(it, commands) } registerCommand0("shdefaultoptions", "Select default options", { DefaultConfigFeatures.onCommand( it.getOrNull(0) ?: "null", it.getOrNull(1) ?: "null" @@ -551,61 +547,6 @@ object Commands { registerCommand("pd", "Disbands the party") { PartyCommands.disband() } } - private fun commandHelp(args: Array<String>) { - var filter: (String) -> Boolean = { true } - val title: String - if (args.size == 1) { - val searchTerm = args[0].lowercase() - filter = { it.lowercase().contains(searchTerm) } - title = "SkyHanni commands with '§e$searchTerm§7'" - } else { - title = "All SkyHanni commands" - } - - val components = mutableListOf<ChatComponentText>() - components.add(ChatComponentText(" \n§7$title:\n")) - - for (command in commands) { - if (!filter(command.name) && !filter(command.description)) continue - val category = command.category - val name = command.name - val color = category.color - - val hoverText = buildList { - add("§e/$name") - if (command.description.isNotEmpty()) { - addDescription(command.description) - } - add("") - add("$color${category.categoryName}") - addDescription(category.description) - } - - components.add(Text.text("$color/$name") { - this.hover = Text.multiline(hoverText) - this.suggest = "/$name" - }) - components.add(ChatComponentText("§7, ")) - } - components.add(ChatComponentText("\n ")) - 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) { |
