summaryrefslogtreecommitdiff
path: root/plugin/src/main/kotlin/moe/nea/archenemy/mojang/MojangVersionMetadata.kt
blob: 1a6cf87e411fbbc1dbb831bc4dac334deab056d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package moe.nea.archenemy.mojang

import kotlinx.serialization.Serializable
import moe.nea.archenemy.util.OSUtil

@Serializable
data class MojangVersionMetadata(
	val assetIndex: AssetIndex,
	val downloads: Map<String, Download>,
	val libraries: List<Library>
) {

	fun getFilteredLibraries(): List<Library> {
		return libraries.filter { !it.name.contains("twitch-platform") && !it.name.contains("twitch-external-platform") }
	}

	@Serializable
	data class Library(
		val name: String,
		val natives: Map<String, String>? = null,
		val extract: ExtractOptions? = null,
	) : java.io.Serializable {
		fun getArtifactCoordinate(): String {
			val classifier = natives?.get(OSUtil.getOsClassifier())
			return name + (if (classifier != null) ":$classifier" else "")
		}

		@Serializable
		data class ExtractOptions(val exclude: List<String> = listOf()) : java.io.Serializable
	}

	@Serializable
	data class Download(
		val sha1: String,
		val size: Long,
		val url: String,
	)

	@Serializable
	data class AssetIndex(
		val id: String,
		val sha1: String,
		val size: Long,
		val totalSize: Long,
		val url: String,
	)

}