aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
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/features
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/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
index 4c6919eea..44fa625e8 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.features.misc.update
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.config.features.About
+import at.hannibal2.skyhanni.config.features.About.UpdateStream
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.utils.ChatUtils
@@ -10,6 +10,7 @@ import at.hannibal2.skyhanni.utils.LorenzLogger
import com.google.gson.JsonElement
import io.github.moulberry.notenoughupdates.util.ApiUtil
import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
+import io.github.notenoughupdates.moulconfig.observer.Property
import io.github.notenoughupdates.moulconfig.processor.MoulConfigProcessor
import moe.nea.libautoupdate.CurrentVersion
import moe.nea.libautoupdate.PotentialUpdate
@@ -75,15 +76,15 @@ object UpdateManager {
logger.log("Reset update state")
}
- fun checkUpdate() {
+ fun checkUpdate(forceDownload: Boolean = false, updateStream: UpdateStream = config.updateStream.get()) {
if (updateState != UpdateState.NONE) {
logger.log("Trying to perform update check while another update is already in progress")
return
}
logger.log("Starting update check")
- var updateStream = config.updateStream.get()
- if (updateStream == About.UpdateStream.RELEASES && isCurrentlyBeta()) {
- updateStream = About.UpdateStream.BETA
+ val currentStream = SkyHanniMod.feature.about.updateStream.get()
+ if (currentStream != UpdateStream.BETA && (updateStream == UpdateStream.BETA || isCurrentlyBeta())) {
+ config.updateStream = Property.of(UpdateStream.BETA)
}
activePromise = context.checkUpdate(updateStream.stream)
.thenAcceptAsync({
@@ -95,8 +96,8 @@ object UpdateManager {
potentialUpdate = it
if (it.isUpdateAvailable) {
updateState = UpdateState.AVAILABLE
- if (config.fullAutoUpdates) {
- ChatUtils.chat("§aSkyHanni found a new update: ${it.update.versionName}, starting to download now. ")
+ if (config.fullAutoUpdates || forceDownload) {
+ ChatUtils.chat("§aSkyHanni found a new update: ${it.update.versionName}, starting to download now.")
queueUpdate()
} else if (config.autoUpdates) {
ChatUtils.chatAndOpenConfig(
@@ -105,6 +106,8 @@ object UpdateManager {
SkyHanniMod.feature.about::autoUpdates
)
}
+ } else if (forceDownload) {
+ ChatUtils.chat("§aSkyHanni didn't find a new update.")
}
}, MinecraftExecutor.OnThread)
}