Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,430 changes: 1,430 additions & 0 deletions ZalithLauncher/src/main/assets/game/unlist_versions.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import com.movtery.zalithlauncher.game.versioninfo.models.VersionManifest
class MinecraftVersion(
val version: VersionManifest.Version,
val type: Type,
val summary: Int?
val summary: Int?,
val urlSuffix: String? = null
): Comparable<MinecraftVersion> {
override fun compareTo(other: MinecraftVersion): Int {
return version.releaseTime.compareTo(other.version.releaseTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@

package com.movtery.zalithlauncher.game.versioninfo

import com.google.gson.reflect.TypeToken
import com.movtery.zalithlauncher.game.addons.mirror.mapBMCLMirrorUrls
import com.movtery.zalithlauncher.game.versioninfo.models.VersionManifest
import com.movtery.zalithlauncher.game.versioninfo.models.filterType
import com.movtery.zalithlauncher.path.PathManager
import com.movtery.zalithlauncher.path.URL_MINECRAFT_VERSION_REPOS
import com.movtery.zalithlauncher.utils.GSON
import com.movtery.zalithlauncher.utils.file.readString
import com.movtery.zalithlauncher.utils.logging.Logger.lWarning
import com.movtery.zalithlauncher.utils.network.fetchStringFromUrls
import com.movtery.zalithlauncher.utils.network.withRetry
Expand Down Expand Up @@ -84,7 +86,8 @@ object MinecraftVersions {
}
}

newManifest ?: throw IllegalStateException("Version manifest is null after all attempts")
val newManifest0 = newManifest ?: throw IllegalStateException("Version manifest is null after all attempts")
mergeUnlistVersions(newManifest0) ?: newManifest0
}.also { newManifest ->
manifest = newManifest
}
Expand Down Expand Up @@ -117,4 +120,32 @@ object MinecraftVersions {
}
}
}

/**
* 尝试从本地合并官方隐藏的版本
*/
private suspend fun mergeUnlistVersions(
currentManifest: VersionManifest
): VersionManifest? {
return withContext(Dispatchers.IO) {
MinecraftVersions::class.java.getResourceAsStream("/assets/game/unlist_versions.json")?.use { input ->
input.readString()
}?.let { unlistVersionJson ->
GSON.fromJson<List<VersionManifest.Version>>(
unlistVersionJson,
object : TypeToken<List<VersionManifest.Version>>() {}.type
)
}?.let { unlistVersions ->
val versions = currentManifest.versions.toMutableList()
versions.addAll(unlistVersions)
versions.sortWith { version, other ->
other.releaseTime.compareTo(version.releaseTime)
}

currentManifest.copy(
versions = versions.toList()
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ val allGameVersions = listOf(
* 愚人节版本类型
*/
enum class AprilFoolsType(
val summary: Int? = null
val summary: Int? = null,
val urlSuffix: String? = null
) {
/**
* [Wiki](https://zh.minecraft.wiki/w/25w14craftmine)
Expand Down Expand Up @@ -86,7 +87,11 @@ enum class AprilFoolsType(
/**
* [Wiki](https://zh.minecraft.wiki/w/15w14a)
*/
TheLoveAndHugsUpdate(R.string.version_summary_fools_the_love_and_hugs_update)
TheLoveAndHugsUpdate(R.string.version_summary_fools_the_love_and_hugs_update),
/**
* [Wiki](https://zh.minecraft.wiki/w/Java%E7%89%882.0)
*/
`2_0`(R.string.version_summary_fools_2_0, "2.0")
}

/**
Expand All @@ -109,7 +114,10 @@ val allAprilFools = listOf(
AprilFoolsVersion("20w14∞", AprilFoolsType.Infinite),
AprilFoolsVersion("3D Shareware v1.34", AprilFoolsType.Minecraft3DShareware),
AprilFoolsVersion("1.RV-Pre1", AprilFoolsType.TrendyUpdate),
AprilFoolsVersion("15w14a", AprilFoolsType.TheLoveAndHugsUpdate)
AprilFoolsVersion("15w14a", AprilFoolsType.TheLoveAndHugsUpdate),
AprilFoolsVersion("2.0_blue", AprilFoolsType.`2_0`),
AprilFoolsVersion("2.0_red", AprilFoolsType.`2_0`),
AprilFoolsVersion("2.0_purple", AprilFoolsType.`2_0`),
)

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Zalith Launcher 2
* Copyright (C) 2025 MovTery <movtery228@qq.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
*/
package com.movtery.zalithlauncher.game.versioninfo.models

import com.google.gson.annotations.SerializedName

data class VersionManifest(
@SerializedName("latest")
val latest: Latest,
@SerializedName("versions")
val versions: List<Version>
) {
data class Latest(
@SerializedName("release")
val release: String,
@SerializedName("snapshot")
val snapshot: String
)

data class Version(
@SerializedName("id")
val id: String,
@SerializedName("type")
val type: String,
@SerializedName("url")
val url: String,
@SerializedName("time")
val time: String,
@SerializedName("releaseTime")
val releaseTime: String,
@SerializedName("sha1")
val sha1: String? = null,
@SerializedName("complianceLevel")
val complianceLevel: Int? = null
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ fun List<VersionManifest.Version>.mapVersion(): List<MinecraftVersion> {
} else {
when (version.type) {
"release" -> MinecraftVersion.Type.Release
"snapshot", "pending" -> MinecraftVersion.Type.Snapshot
"snapshot", "pending", "unobfuscated" -> MinecraftVersion.Type.Snapshot
"old_beta" -> MinecraftVersion.Type.OldBeta
"old_alpha" -> MinecraftVersion.Type.OldAlpha
else -> MinecraftVersion.Type.Unknown
}
},
summary = aprilFoolsVersion?.type?.summary //暂时仅为愚人节版提供描述
summary = aprilFoolsVersion?.type?.summary, //暂时仅为愚人节版提供描述
urlSuffix = aprilFoolsVersion?.type?.urlSuffix
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ object AllSettings : SettingsRegistry() {
/**
* 摇杆前进锁判定范围
*/
val joystickLockThreshold = intSetting("joystickLockThreshold", 30, 5..50)
val joystickLockThreshold = intSetting("joystickLockThreshold", 30, 5..100)

/**
* 游戏中摇杆移动组件是否可锁定
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ class SplashActivity : BaseAppCompatActivity(refreshData = false) {
}

private fun checkAllTask() {
//检查应用 assets 目录
listAssetsPath("runtimes").forEach { filePath ->
lInfo("The launcher contains the runtime environment: $filePath")
}

unpackItems.forEach { item ->
if (!item.task.isNeedUnpack()) {
item.isFinished = true
Expand All @@ -152,6 +157,30 @@ class SplashActivity : BaseAppCompatActivity(refreshData = false) {
}
}

private fun listAssetsPath(root: String): List<String> {
return buildList {
val rootFiles = runCatching {
assets.list(root)?.takeIf { it.isNotEmpty() }
}.getOrNull()
if (rootFiles != null) {
rootFiles.forEach { child ->
val childPath = "$root/$child"
val childFiles = runCatching {
assets.list(childPath)?.takeIf { it.isNotEmpty() }
}.getOrNull()

if (childFiles != null) {
addAll(listAssetsPath(childPath))
} else {
add(childPath)
}
}
} else {
add(root)
}
}
}

private fun startAllTask() {
lifecycleScope.launch {
val jobs = unpackItems
Expand Down
Loading