Skip to content

Commit

Permalink
Fixed /viewrecipe replace breaking pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal002 committed Oct 6, 2024
1 parent 1e786d9 commit 7c26ef7
Showing 1 changed file with 12 additions and 3 deletions.
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

0 comments on commit 7c26ef7

Please sign in to comment.