Skip to content

Commit

Permalink
Now url can be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
LionZXY committed Jan 4, 2021
1 parent f22f5b7 commit b2dcbe7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
dependencies {
implementation 'com.google.code.gson:gson:2.8.5'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation 'com.github.LionZXY:mclauncher-api:d4d12dc77e'
implementation 'com.github.tomsik68:mclauncher-api:master-SNAPSHOT'
implementation "no.tornado:tornadofx:1.7.17"
implementation 'de.codecentric.centerdevice:javafxsvg:1.3.0'
implementation 'com.github.LionZXY:oslib:master-SNAPSHOT'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import java.io.File

enum class MinecraftModpack(
val modpackName: String,
val initialDownloadLink: String,
val updateJsonLink: String,
val updateHostLink: String,
val defaultServer: ServerInfo,
val initialDownloadLink: String?,
val updateJsonLink: String?,
val updateHostLink: String?,
val defaultServer: ServerInfo?,
val version: String
) {
@SerializedName("MIDGARD")
Expand All @@ -24,6 +24,7 @@ enum class MinecraftModpack(
ServerInfo("minecraft.glitchless.ru", "Glitchless Server", null, 25565),
"1.12.2-forge1.12.2-14.23.5.2836"
),

@SerializedName("LIGHT")
LIGHT(
"Light",
Expand All @@ -32,6 +33,14 @@ enum class MinecraftModpack(
"https://minecraft.glitchless.ru/minecraft_dist/first_server/",
ServerInfo("minecraft.glitchless.ru", "Glitchless Server", null, 25565),
"1.12.2-forge1.12.2-14.23.5.2836"
),
TEST(
modpackName = "Test",
initialDownloadLink = null,
updateJsonLink = null,
updateHostLink = null,
defaultServer = ServerInfo("minecraft.glitchless.ru", "Glitchless Server", null, 25565),
version = "1.16.4"
);

override fun toString(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class InitialDownloader : IDownloader {
override fun download(minecraft: MinecraftContext) {
val dist = File(ConfigHelper.getTemporaryDirectory(), "minecraft.zip")
minecraft.progressMonitor.setStatus("Загрузка модов...")
val url = minecraft.modpack.initialDownloadLink
if (url.isNullOrEmpty()) {
markDownloaded(minecraft)
return
}
FileUtils.downloadFileWithProgress(
minecraft.modpack.initialDownloadLink,
dist,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ class UpdateDownloader : IDownloader {
minecraft.progressMonitor.setStatus("Получение списка обновлений с сервера...")
val lastUpdateTimestamp =
ConfigHelper.config.modpackDownloadedInfo[minecraft.modpack.modpackName]!!.lastUpdateFromChangeLog ?: 0
val json = HttpUtils.httpGet(minecraft.modpack.updateJsonLink)
val url = minecraft.modpack.updateJsonLink
if (url.isNullOrEmpty()) {
return
}
val json = HttpUtils.httpGet(url)
val type = object : TypeToken<Map<String, Map<String, Action>>>() {}.type
val map = gson.fromJson<Map<String, Map<String, Action>>>(json, type)
val changeLog = map.map { it.key.toLong() to it.value }
Expand Down
27 changes: 27 additions & 0 deletions src/main/kotlin/ru/lionzxy/tplauncher/utils/DebugMonitoring.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package ru.lionzxy.tplauncher.utils

import sk.tomsik68.mclauncher.api.ui.IProgressMonitor

class DebugMonitoring : IProgressMonitor {
private var currentProgress = 0
private var maxLen = 0

override fun setProgress(progress: Int) {
currentProgress = progress
println("#setProgress $progress/$maxLen")
}

override fun setMax(len: Int) {
println("#max $len")
maxLen = len
}

override fun incrementProgress(amount: Int) {
setProgress(currentProgress + amount)
}

override fun setStatus(status: String?) {
println("#setStatus $status")
}

}

0 comments on commit b2dcbe7

Please sign in to comment.