Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: /viewrecipe replace breaking pages #2679

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
Loading