aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt23
1 files changed, 18 insertions, 5 deletions
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 fbfb1a640..cbdc626ac 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt
@@ -2,23 +2,36 @@ package at.hannibal2.skyhanni.features.commands
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
+import at.hannibal2.skyhanni.utils.ChatUtils.senderIsSkyhanni
import at.hannibal2.skyhanni.utils.HypixelCommands
import at.hannibal2.skyhanni.utils.NEUItems
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object ViewRecipeCommand {
private val config get() = SkyHanniMod.feature.misc.commands
+ /**
+ * REGEX-TEST: /viewrecipe aspect of the end
+ * REGEX-TEST: /viewrecipe aspect_of_the_end
+ * REGEX-TEST: /viewrecipe ASPECT_OF_THE_END
+ */
+ private val pattern by RepoPattern.pattern(
+ "commands.viewrecipe",
+ "\\/viewrecipe (?<item>.*)"
+ )
+
@SubscribeEvent
fun onMessageSendToServer(event: MessageSendToServerEvent) {
if (!config.viewRecipeLowerCase) return
- val message = event.message
- if (!message.startsWith("/viewrecipe ", ignoreCase = true)) return
+ if (event.senderIsSkyhanni()) return
+
+ val item = pattern.matchMatcher(event.message.lowercase()) {
+ group("item").uppercase().replace(" ", "_")
+ } ?: return
- if (message == message.uppercase()) return
- val item = message.uppercase().substringAfter("viewrecipe").trim()
- if (item.isEmpty()) return
event.isCanceled = true
HypixelCommands.viewRecipe(item)
}