From 71a6b08b376be7d742107df982905cac0d7ecf70 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Tue, 29 Aug 2023 20:25:01 +0200 Subject: Add default option selector #400 * Allow for update only options * Clean/Split up mass configuration options * Merge remote-tracking branch 'origin/beta' into feat/defaultoptions * Fix merge errors --- .../hannibal2/skyhanni/config/commands/Commands.kt | 26 ++++++++++++++++++++-- .../skyhanni/config/commands/SimpleCommand.java | 4 ++-- 2 files changed, 26 insertions(+), 4 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/config/commands') diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index b87961a2c..73b6cb46d 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -27,6 +27,7 @@ import at.hannibal2.skyhanni.features.misc.CollectionTracker import at.hannibal2.skyhanni.features.misc.MarkedPlayerManager import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil +import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures import at.hannibal2.skyhanni.features.slayer.SlayerItemProfitTracker import at.hannibal2.skyhanni.test.PacketTest import at.hannibal2.skyhanni.test.SkyHanniConfigSearchResetCommand @@ -105,6 +106,11 @@ object Commands { registerCommand("skyhanni", "Opens the main SkyHanni config", openMainMenu) registerCommand("ff", "Opens the Farming Fortune Guide") { openFortuneGuide() } registerCommand("shcommands", "Shows this list") { commandHelp(it) } + registerCommand0("shdefaultoptions", "Select default options", { + DefaultConfigFeatures.onCommand( + it.getOrNull(0) ?: "null", it.getOrNull(1) ?: "null" + ) + }, DefaultConfigFeatures::onComplete) } private fun usersNormal() { @@ -308,8 +314,24 @@ object Commands { config.outdatedItems.clear() } - private fun registerCommand(name: String, description: String, function: (Array) -> Unit) { - ClientCommandHandler.instance.registerCommand(SimpleCommand(name, createCommand(function))) + private fun registerCommand( + name: String, + description: String, + function: (Array) -> Unit + ) = registerCommand0(name, description, function) + + private fun registerCommand0( + name: String, + description: String, + function: (Array) -> Unit, + autoComplete: ((Array) -> List) = { listOf() } + ) { + ClientCommandHandler.instance.registerCommand( + SimpleCommand( + name, + createCommand(function), + { a, b, c -> autoComplete(b) }) + ) commands.add(CommandInfo(name, description, currentCategory)) } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java index fa2c310de..9ff8ade64 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/SimpleCommand.java @@ -32,9 +32,9 @@ public class SimpleCommand extends CommandBase { public abstract void processCommand(ICommandSender sender, String[] args); } - public abstract static class TabCompleteRunnable { + public interface TabCompleteRunnable { - public abstract List tabComplete(ICommandSender sender, String[] args, BlockPos pos); + List tabComplete(ICommandSender sender, String[] args, BlockPos pos); } public boolean canCommandSenderUseCommand(ICommandSender sender) { -- cgit