aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-05-30 12:59:00 +0200
committerGitHub <noreply@github.com>2024-05-30 12:59:00 +0200
commit5d89d56e1a480ae26f325c995a66a4b40a436638 (patch)
tree7f2eb949b3d5ac731a12cbe31e7fedde9910c452 /src/main/java/at/hannibal2/skyhanni/features
parente058044eca6f0b6330de6e14eaa9b11a9ef060ae (diff)
downloadskyhanni-5d89d56e1a480ae26f325c995a66a4b40a436638.tar.gz
skyhanni-5d89d56e1a480ae26f325c995a66a4b40a436638.tar.bz2
skyhanni-5d89d56e1a480ae26f325c995a66a4b40a436638.zip
Fix: /viewrecipe (#1939)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-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)
}