From 51cfe4de8e902e614ea73627fce7d34eabea2e62 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 26 Oct 2023 18:17:10 +0200 Subject: Added support for tab completing the items with recipe in Hypixel command /viewrecipe. --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 ++-- .../skyhanni/config/features/CommandsConfig.java | 6 ++++++ .../skyhanni/features/commands/ViewRecipeCommand.kt | 21 ++++++++++++++++++++- .../features/commands/tabcomplete/TabComplete.kt | 2 ++ 4 files changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 45042af50..76b3c0aa1 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -69,9 +69,9 @@ import at.hannibal2.skyhanni.features.combat.mobs.MobHighlight import at.hannibal2.skyhanni.features.combat.mobs.SpawnTimers import at.hannibal2.skyhanni.features.commands.PartyCommands import at.hannibal2.skyhanni.features.commands.SendCoordinatedCommand +import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand 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 @@ -421,7 +421,7 @@ class SkyHanniMod { loadModule(WikiCommand()) loadModule(SendCoordinatedCommand()) loadModule(WarpIsCommand()) - loadModule(ViewRecipeCommand()) + loadModule(ViewRecipeCommand) loadModule(PartyCommands) loadModule(SummoningMobManager()) loadModule(AreaMiniBossFeatures()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java index 6f7607f9b..d1475d522 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/CommandsConfig.java @@ -60,6 +60,12 @@ public class CommandsConfig { @ConfigEditorBoolean @FeatureToggle public boolean partyCommands = true; + + @Expose + @ConfigOption(name = "Viewrecipe Items", desc = "Tab complete items with recipe in the the Hypixel command §e/viewrecipe§7.") + @ConfigEditorBoolean + @FeatureToggle + public boolean viewrecipeItems = true; } @Expose 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 0563f21ee..4464959e2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/ViewRecipeCommand.kt @@ -3,10 +3,11 @@ package at.hannibal2.skyhanni.features.commands import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.NEUItems import net.minecraft.network.play.client.C01PacketChatMessage import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class ViewRecipeCommand { +object ViewRecipeCommand { private val config get() = SkyHanniMod.feature.commands @SubscribeEvent @@ -22,4 +23,22 @@ class ViewRecipeCommand { } } } + + val list by lazy { + val list = mutableListOf() + for ((key, value) in NEUItems.manager.itemInformation) { + if (value.has("recipe")) { + list.add(key.lowercase()) + } + } + list + } + + fun customTabComplete(command: String): List? { + if (command == "viewrecipe" && config.tabComplete.viewrecipeItems) { + return list + } + + return null + } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt index 9c03e3a87..a835efd38 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/TabComplete.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.commands.tabcomplete import at.hannibal2.skyhanni.features.commands.PartyCommands +import at.hannibal2.skyhanni.features.commands.ViewRecipeCommand import at.hannibal2.skyhanni.features.misc.CollectionTracker object TabComplete { @@ -26,6 +27,7 @@ object TabComplete { PlayerTabComplete.handleTabComplete(command)?.let { return it } CollectionTracker.handleTabComplete(command)?.let { return it } PartyCommands.customTabComplete(command)?.let { return it } + ViewRecipeCommand.customTabComplete(command)?.let { return it } return null } -- cgit