Downloads

internal object Downloads

Fetching the per-version mapping artifacts RemapCache provisions from: where they live, how to retry a transient failure, and how to verify what came back. Nothing here knows about the cache layout or the masking-loader hop — it hands back files.

Runs on the game loader, like its caller: MC's bundled Gson and the JDK HttpClient both live there.

Properties

Link copied to clipboard
private const val ATTEMPTS: Int = 3
Link copied to clipboard
Link copied to clipboard
private val FILE_TIMEOUT: Duration
Link copied to clipboard
private val HTTP: HttpClient
Link copied to clipboard
private val JSON_TIMEOUT: Duration
Link copied to clipboard
private const val MANIFEST: String
Link copied to clipboard
private const val SPIGOT_BUILDDATA: String

The REST API, NOT /stash/projects/.../raw/...: the raw path sits behind Cloudflare's interactive challenge and answers a plain GET with an HTML page. REST is not challenged.

Link copied to clipboard
private const val SPIGOT_VERSIONS: String

BuildTools' own per-version lookup. Required, not a convenience: BuildData REPLACES mappings/ each version rather than accumulating, so a version's csrg exists only at the commit refs.BuildData pins — master carries none of them. The commit is also the integrity gate, since BuildData publishes no hash.

Functions

Link copied to clipboard
private fun checkStatus(code: Int, url: String)

Map a retryable HTTP status (429 / 5xx) to an IOException so withRetry retries it; leave 4xx permanent.

Link copied to clipboard
fun download(url: String, dest: Path, expectedSha1: String? = null): Path
Link copied to clipboard
fun downloadClientMappings(version: String, dir: Path): Path

Mojang manifest -> the version's JSON -> client_mappings url.

Link copied to clipboard

SpigotMC BuildData's per-version CLASS mappings (obf -> spigot), the axis Mojang's proguard cannot supply: spigot's class names are spigot's own invention, derivable from no Mojang artifact.

Link copied to clipboard
fun extractZipEntry(zip: Path, entry: String, dest: Path)
Link copied to clipboard
private fun get(url: String): String
Link copied to clipboard
Link copied to clipboard

The MCP here is Mod Coder Pack (forge's obf->srg mappings), not this mod's Model Context Protocol.

Link copied to clipboard
private fun sha1Of(file: Path): String

SHA-1 of file, streamed (client_mappings is ~9MB). Hex, compared case-insensitively against Mojang's published downloads.*.sha1.

Link copied to clipboard
private fun <T> withRetry(what: String, block: () -> T): T

Retry a synchronous, idempotent GET on TRANSIENT failures only: IOException (connection reset/abort/ timeout) and 429/5xx. 4xx is permanent → not retried. 3 attempts, exponential backoff. The JDK HttpClient's own retry is connection-establishment-only.