Skip to content

Commit

Permalink
refactor: download -all jars for base and runner updates
Browse files Browse the repository at this point in the history
  • Loading branch information
frederickbaier committed Oct 5, 2024
1 parent af8e2ec commit b12931b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
package eu.thesimplecloud.launcher.updater

import eu.thesimplecloud.api.directorypaths.DirectoryPaths
import eu.thesimplecloud.runner.utils.Downloader
import java.io.File

class BaseUpdater : AbstractUpdater(
Expand All @@ -41,6 +42,18 @@ class BaseUpdater : AbstractUpdater(
return getVersionFromManifestFile(this.updateFile)
}

override fun downloadJarsForUpdate() {
val file = File(DirectoryPaths.paths.storagePath + "base.jar")

val version = getVersionToInstall()
?: throw RuntimeException("Cannot perform update. Is the update server down?")

Downloader().userAgentDownload(
"https://repo.simplecloud.app/releases/eu/thesimplecloud/simplecloud/simplecloud-base/$version/simplecloud-base-$version-all.jar",
file
)
}

override fun executeJar() {
//do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import eu.thesimplecloud.jsonlib.JsonLib
import eu.thesimplecloud.launcher.startup.Launcher
import eu.thesimplecloud.runner.RunnerFileProvider
import eu.thesimplecloud.runner.dependency.AdvancedCloudDependency
import eu.thesimplecloud.runner.utils.Downloader
import eu.thesimplecloud.runner.utils.WebContentLoader
import java.io.File
import java.net.URLClassLoader
Expand Down Expand Up @@ -54,13 +55,23 @@ class RunnerUpdater(
//TODO update to new url
val urlstring =
"https://update.thesimplecloud.eu/latestVersion/${getCurrentVersion()}?channel=${updateChannel.toChannelString()}"
val content =
WebContentLoader().loadContent(urlstring)
?: return null
val content = WebContentLoader().loadContent(urlstring) ?: return null
this.versionToInstall = JsonLib.fromJsonString(content).getString("latestVersion")
return this.versionToInstall
}

override fun downloadJarsForUpdate() {
val file = File("runner-update.jar")

val version = getVersionToInstall()
?: throw RuntimeException("Cannot perform update. Is the update server down?")

Downloader().userAgentDownload(
"https://repo.simplecloud.app/releases/eu/thesimplecloud/simplecloud/simplecloud-runner/$version/simplecloud-runner-$version-all.jar",
file
)
}

override fun executeJar() {
val file = File("runner-update.jar")
val currentRunnerFile = RunnerFileProvider.RUNNER_FILE
Expand Down

0 comments on commit b12931b

Please sign in to comment.