-
-
Notifications
You must be signed in to change notification settings - Fork 188
Add autocomplete to /ahs, /bzs, & /bz #2378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package de.hysky.skyblocker.skyblock; | ||
|
|
||
| import static net.fabricmc.fabric.api.client.command.v2.ClientCommands.argument; | ||
| import static net.fabricmc.fabric.api.client.command.v2.ClientCommands.literal; | ||
|
|
||
| import com.mojang.brigadier.arguments.StringArgumentType; | ||
| import com.mojang.brigadier.context.CommandContext; | ||
| import com.mojang.brigadier.suggestion.Suggestions; | ||
| import com.mojang.brigadier.suggestion.SuggestionsBuilder; | ||
| import com.mojang.brigadier.tree.LiteralCommandNode; | ||
| import de.hysky.skyblocker.annotations.Init; | ||
| import de.hysky.skyblocker.skyblock.searchoverlay.SearchOverManager; | ||
| import de.hysky.skyblocker.utils.NEURepoManager; | ||
| import de.hysky.skyblocker.utils.Utils; | ||
| import de.hysky.skyblocker.utils.command.CommandUtils; | ||
| import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; | ||
| import net.minecraft.commands.SharedSuggestionProvider; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.function.Supplier; | ||
|
|
||
| public class AuctionBazaarAutocomplete { | ||
| public static @Nullable LiteralCommandNode<FabricClientCommandSource> ahsNode; | ||
| public static @Nullable LiteralCommandNode<FabricClientCommandSource> ahsearchNode; | ||
| public static @Nullable LiteralCommandNode<FabricClientCommandSource> bzNode; | ||
| public static @Nullable LiteralCommandNode<FabricClientCommandSource> bazaarNode; | ||
|
|
||
| @Init(priority = 100) // Load after SearchOverManager | ||
| public static void init() { | ||
| NEURepoManager.runAsyncAfterLoad(AuctionBazaarAutocomplete::createNodes); | ||
| } | ||
|
|
||
| // since /bzs is only client-side it needs separate handling | ||
| public static CompletableFuture<Suggestions> suggestBzs(CommandContext<FabricClientCommandSource> context, SuggestionsBuilder builder) { | ||
| return SharedSuggestionProvider.suggest(SearchOverManager.getBazaarItems(), builder); | ||
| } | ||
|
|
||
| private static void createNodes() { | ||
| ahsNode = createNode("ahs", SearchOverManager::getAuctionItems); | ||
| ahsearchNode = createNode("ahsearch", SearchOverManager::getAuctionItems); | ||
| bzNode = createNode("bz", SearchOverManager::getBazaarItems); | ||
| bazaarNode = createNode("bazaar", SearchOverManager::getBazaarItems); | ||
| } | ||
|
|
||
| private static LiteralCommandNode<FabricClientCommandSource> createNode(String command, Supplier<Iterable<String>> suggester) { | ||
| return literal(command) | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .executes(CommandUtils.noOp) | ||
| .then(argument("item", StringArgumentType.greedyString()) | ||
| .suggests((_, builder) -> SharedSuggestionProvider.suggest(suggester.get(), builder)) | ||
| .executes(CommandUtils.noOp)) | ||
| .build(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| import de.hysky.skyblocker.config.configs.UIAndVisualsConfig; | ||
| import de.hysky.skyblocker.debug.Debug; | ||
| import de.hysky.skyblocker.injected.SkyblockerStack; | ||
| import de.hysky.skyblocker.skyblock.AuctionBazaarAutocomplete; | ||
| import de.hysky.skyblocker.skyblock.item.tooltip.info.TooltipInfoType; | ||
| import de.hysky.skyblocker.skyblock.itemlist.ItemRepository; | ||
| import de.hysky.skyblocker.skyblock.museum.Donation; | ||
|
|
@@ -19,6 +20,7 @@ | |
| import de.hysky.skyblocker.utils.FlexibleItemStack; | ||
| import de.hysky.skyblocker.utils.ItemUtils; | ||
| import de.hysky.skyblocker.utils.NEURepoManager; | ||
| import de.hysky.skyblocker.utils.Utils; | ||
| import de.hysky.skyblocker.utils.scheduler.MessageScheduler; | ||
| import io.github.moulberry.repo.data.NEUItem; | ||
| import io.github.moulberry.repo.util.NEUId; | ||
|
|
@@ -89,13 +91,30 @@ public static void init() { | |
|
|
||
| private static void registerSearchCommands(CommandDispatcher<FabricClientCommandSource> dispatcher, CommandBuildContext registryAccess) { | ||
| if (SkyblockerConfigManager.get().uiAndVisuals.searchOverlay.enableCommands) { | ||
| dispatcher.register(literal("ahs").executes(_ -> startCommand(true, ""))); | ||
| dispatcher.register(literal("bzs").executes(_ -> startCommand(false, ""))); | ||
|
|
||
| dispatcher.register(literal("ahs").then(argument("item", StringArgumentType.greedyString()) | ||
|
Comment on lines
-92
to
-95
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to look into this more but some of these are hypixel commands, which would spam the logs? Idk what the old code is doing here tbh. Either way, commands that are hypixel shouldn't be here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite sure what you mean here. |
||
| dispatcher.register(literal("ahs") | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .executes(_ -> startCommand(true, ""))); | ||
| dispatcher.register(literal("ahsearch") | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .executes(_ -> startCommand(true, ""))); | ||
| dispatcher.register(literal("bzs") | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .executes(_ -> startCommand(false, ""))); | ||
|
|
||
| dispatcher.register(literal("ahs") | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .then(argument("item", StringArgumentType.greedyString()) | ||
| .executes(context -> startCommand(true, StringArgumentType.getString(context, "item")) | ||
| ))); | ||
| dispatcher.register(literal("ahsearch") | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .then(argument("item", StringArgumentType.greedyString()) | ||
| .executes(context -> startCommand(true, StringArgumentType.getString(context, "item")) | ||
| ))); | ||
| dispatcher.register(literal("bzs").then(argument("item", StringArgumentType.greedyString()) | ||
| dispatcher.register(literal("bzs") | ||
| .requires(_ -> Utils.isOnSkyblock()) | ||
| .then(argument("item", StringArgumentType.greedyString()) | ||
| .suggests(AuctionBazaarAutocomplete::suggestBzs) | ||
| .executes(context -> startCommand(false, StringArgumentType.getString(context, "item")) | ||
| ))); | ||
| } | ||
|
|
@@ -215,6 +234,14 @@ private static void loadItems() { | |
| SearchOverManager.namesToNeuId = namesToNeuId; | ||
| } | ||
|
|
||
| public static HashSet<String> getBazaarItems() { | ||
| return bazaarItems; | ||
| } | ||
|
|
||
| public static HashSet<String> getAuctionItems() { | ||
| return auctionItems; | ||
| } | ||
|
|
||
| /** | ||
| * Receives data when a search is started and resets values | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like some of these commands are our own? For the ones that are our own we don't need to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of those are our own, the only one that's our own in this PR is
/bzswhich is already not included there (and has its own handling elsewhere).