Skip to content

Commit

Permalink
feat: add prompt to switch update channels if on non-release
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Jan 17, 2024
1 parent fd1b292 commit bc9f035
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/Skytils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package gg.skytils.skytilsmod

import gg.essential.api.EssentialAPI
import gg.essential.universal.UChat
import gg.essential.universal.UKeyboard
import gg.skytils.event.Events
Expand Down Expand Up @@ -397,6 +398,20 @@ class Skytils {
if (config.overrideReparty || !cch.commands.containsKey("rp")) {
cch.commandMap["rp"] = RepartyCommand
}

if (UpdateChecker.currentVersion.specialVersionType != UpdateChecker.UpdateType.RELEASE && config.updateChannel == 2) {
if (ModChecker.canShowNotifications) {
EssentialAPI.getNotifications().push("Skytils Update Checker", "You are on a development version of Skytils. Click here to change your update channel to pre-release.") {
onAction = {
config.updateChannel = 1
config.markDirty()
EssentialAPI.getNotifications().push("Skytils Update Checker", "Your update channel has been changed to pre-release.", duration = 3f)
}
}
} else {
UChat.chat("${prefix} §fYou are on a development version of Skytils. Change your update channel to pre-release to get notified of new updates.")
}
}
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/gg/skytils/skytilsmod/core/UpdateChecker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ object UpdateChecker {
val updateDownloadURL: String
get() = updateAsset.downloadUrl

val currentTag = Skytils.VERSION.substringBefore("-dev")
val currentVersion = SkytilsVersion(currentTag)

fun getJarNameFromUrl(url: String): String {
return url.split(Regex("/")).last()
}
Expand Down Expand Up @@ -164,9 +167,6 @@ object UpdateChecker {
else -> return println("Update Channel set as none")
}
val latestTag = latestRelease.tagName
val currentTag = Skytils.VERSION.substringBefore("-dev")

val currentVersion = SkytilsVersion(currentTag)
val latestVersion = SkytilsVersion(latestTag.substringAfter("v"))
if (currentVersion < latestVersion) {
updateObj = latestRelease
Expand Down

0 comments on commit bc9f035

Please sign in to comment.