summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config
diff options
context:
space:
mode:
authorEmpa <42304516+ItsEmpa@users.noreply.github.com>2024-04-28 16:45:37 +0200
committerGitHub <noreply@github.com>2024-04-28 16:45:37 +0200
commitc8d4beac252f66a4988a71cdc8aba60207252528 (patch)
treed4ba45c40a6cfe24d93db15b772eb2430f0fa2f3 /src/main/java/at/hannibal2/skyhanni/config
parentae9482ca94504e809c8effa02530fa4697845542 (diff)
downloadskyhanni-c8d4beac252f66a4988a71cdc8aba60207252528.tar.gz
skyhanni-c8d4beac252f66a4988a71cdc8aba60207252528.tar.bz2
skyhanni-c8d4beac252f66a4988a71cdc8aba60207252528.zip
Feature: Update command (#1578)
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt27
1 files changed, 27 insertions, 0 deletions
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<String>) {
+ 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<String>) -> Unit) {
if (commands.any { it.name.equals(name, ignoreCase = true) }) {
error("The command '$name is already registered!'")