From c8d4beac252f66a4988a71cdc8aba60207252528 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Sun, 28 Apr 2024 16:45:37 +0200 Subject: Feature: Update command (#1578) --- .../hannibal2/skyhanni/config/commands/Commands.kt | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/config') 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 6212c35b0..0ba4da096 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.SkillAPI import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigGuiManager +import at.hannibal2.skyhanni.config.features.About.UpdateStream import at.hannibal2.skyhanni.data.ChatClickActionManager import at.hannibal2.skyhanni.data.ChatManager import at.hannibal2.skyhanni.data.GardenCropMilestonesCommunityFix @@ -54,6 +55,7 @@ import at.hannibal2.skyhanni.features.misc.MiscFeatures import at.hannibal2.skyhanni.features.misc.discordrpc.DiscordRPCManager import at.hannibal2.skyhanni.features.misc.limbo.LimboTimeTracker import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures +import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.misc.visualwords.VisualWordGui import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker @@ -368,6 +370,10 @@ object Commands { "shkingfix", "Reseting the local King Talisman Helper offset." ) { KingTalismanHelper.kingFix() } + registerCommand( + "shupdate", + "Updates the mod to the specified update stream." + ) { forceUpdate(it) } } private fun developersDebugFeatures() { @@ -586,6 +592,27 @@ object Commands { storage.outdatedItems.clear() } + private fun forceUpdate(args: Array) { + val currentStream = SkyHanniMod.feature.about.updateStream.get() + val arg = args.firstOrNull() ?: "current" + val updateStream = when { + arg.equals("(?i)(?:full|release)s?".toRegex()) -> UpdateStream.RELEASES + arg.equals("(?i)(?:beta|latest)s?".toRegex()) -> UpdateStream.BETA + else -> currentStream + } + + if (updateStream == UpdateStream.BETA && (currentStream != UpdateStream.BETA || UpdateManager.isCurrentlyBeta())) { + ChatUtils.clickableChat( + "Are you sure you want to switch to beta? These versions may be less stable.", + onClick = { + UpdateManager.checkUpdate(true, updateStream) + } + ) + } else { + UpdateManager.checkUpdate(true, updateStream) + } + } + private fun registerCommand(name: String, description: String, function: (Array) -> Unit) { if (commands.any { it.name.equals(name, ignoreCase = true) }) { error("The command '$name is already registered!'") -- cgit