Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;

import de.hysky.skyblocker.skyblock.AuctionBazaarAutocomplete;
import de.hysky.skyblocker.skyblock.CallAutocomplete;
import de.hysky.skyblocker.skyblock.ChaptersAutocomplete;
import de.hysky.skyblocker.skyblock.JoinInstanceAutocomplete;
Expand Down Expand Up @@ -34,6 +35,10 @@ public CommandNode<? extends SharedSuggestionProvider> modifyCommandSuggestions(
case String s when s.equals("rngmeter") && RngMeterAutocomplete.longCommand != null -> RngMeterAutocomplete.longCommand;
case String s when s.equals("rng") && RngMeterAutocomplete.shortCommand != null -> RngMeterAutocomplete.shortCommand;
case String s when s.equals("call") && CallAutocomplete.commandNode != null -> CallAutocomplete.commandNode;
case String s when s.equals("ahs") && AuctionBazaarAutocomplete.ahsNode != null -> AuctionBazaarAutocomplete.ahsNode;
case String s when s.equals("ahsearch") && AuctionBazaarAutocomplete.ahsearchNode != null -> AuctionBazaarAutocomplete.ahsearchNode;
case String s when s.equals("bz") && AuctionBazaarAutocomplete.bzNode != null -> AuctionBazaarAutocomplete.bzNode;
case String s when s.equals("bazaar") && AuctionBazaarAutocomplete.bazaarNode != null -> AuctionBazaarAutocomplete.bazaarNode;

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Contributor Author

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 /bzs which is already not included there (and has its own handling elsewhere).

case String s when s.equals("chapter") && ChaptersAutocomplete.singularCommandNode != null -> ChaptersAutocomplete.singularCommandNode;
case String s when s.equals("chapters") && ChaptersAutocomplete.pluralCommandNode != null -> ChaptersAutocomplete.pluralCommandNode;
default -> original;
Expand Down
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
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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"))
)));
}
Expand Down Expand Up @@ -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
*
Expand Down
Loading