From 1446e5aea63a4e3f672289b4f048920aa1e7234f Mon Sep 17 00:00:00 2001 From: Walker Selby Date: Thu, 26 Oct 2023 16:19:14 +0100 Subject: Allow IDs in viewrecipe to be lowercase (#593) Adds support for lower case item ids to the Hypixel command /viewrecipe. #593 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 ++ .../features/commands/ViewRecipeCommand.kt | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 0e2e0fd9c..45042af50 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -71,6 +71,7 @@ import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.commands.SendCoordinatedCommand import at.hannibal2.skyhanni.features.commands.WarpIsCommand import at.hannibal2.skyhanni.features.commands.WikiCommand +import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand import at.hannibal2.skyhanni.features.commands.tabcomplete.GetFromSacksTabComplete import at.hannibal2.skyhanni.features.commands.tabcomplete.PlayerTabComplete import at.hannibal2.skyhanni.features.commands.tabcomplete.WarpTabComplete @@ -420,6 +421,7 @@ class SkyHanniMod { loadModule(WikiCommand()) loadModule(SendCoordinatedCommand()) loadModule(WarpIsCommand()) + loadModule(ViewRecipeCommand()) loadModule(PartyCommands) loadModule(SummoningMobManager()) loadModule(AreaMiniBossFeatures()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt new file mode 100644 index 000000000..f52ad10e3 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt @@ -0,0 +1,22 @@ +package at.hannibal2.skyhanni.features.commands + +import at.hannibal2.skyhanni.events.PacketEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import net.minecraft.network.play.client.C01PacketChatMessage +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class ViewRecipeCommand { + + @SubscribeEvent + fun onSendPacket(event: PacketEvent.SendEvent) { + val packet = event.packet + if (packet is C01PacketChatMessage) { + if (packet.message == packet.message.uppercase()) return + val message = packet.message.lowercase() + if (message.startsWith("/viewrecipe ")) { + event.isCanceled = true + LorenzUtils.sendMessageToServer(message.uppercase()) + } + } + } +} -- cgit