From ff119419cce3e192012aee9e438911ffeb8d8519 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Sun, 6 Oct 2024 22:49:45 +0200 Subject: Fixed /viewrecipe replace breaking pages (#2679) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../skyhanni/features/commands/ViewRecipeCommand.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt index e3d6a5713..dbaf037ca 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.NEUItems +import at.hannibal2.skyhanni.utils.NumberUtil.isInt import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -30,12 +31,20 @@ object ViewRecipeCommand { if (!config.viewRecipeLowerCase) return if (event.senderIsSkyhanni()) return - val item = pattern.matchMatcher(event.message.lowercase()) { - group("item").uppercase().replace(" ", "_") + val input = pattern.matchMatcher(event.message.lowercase()) { + group("item").uppercase() } ?: return + val args = input.split(" ") + val endsWithPageNumber = args.last().isInt() + val finalCommand = if (endsWithPageNumber) { + "${args.dropLast(1).joinToString("_")} ${args.last()}" + } else { + input.replace(" ", "_") + } + event.cancel() - HypixelCommands.viewRecipe(item) + HypixelCommands.viewRecipe(finalCommand) } val list by lazy { -- cgit