summaryrefslogtreecommitdiff
path: root/plugin/src/main/kotlin/moe/nea/archenemy/mojang/OfficialMappingDependency.kt
blob: 8617edecee613fa32df3b69814030807053df2f7 (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
package moe.nea.archenemy.mojang

import moe.nea.archenemy.MCSide
import org.gradle.api.artifacts.Dependency
import org.gradle.api.provider.Provider
import java.io.File
import java.security.MessageDigest

class OfficialMappingDependency(
    val side: MCSide,
    val version: String,
    val dependency: Provider<Dependency>
) : MappingDependency,
    Provider<Dependency> by dependency {

    override fun updateHash(digest: MessageDigest) {
        digest.update("official")
        digest.updateField("side", side.toString())
        digest.updateField("version", version)
    }

    override fun title(): String {
        return "official-$side-${version.replace(".","_")}"
    }

    override fun findMapping(files: Set<File>): File? {
        return files.singleOrNull {
            it.name == "minecraft-${version}-${side}-mappings.txt"
        }
    }

    override fun applyMapping(
        mappingsFile: File,
        sourceFile: File,
        targetFile: File,
        sourceNameSpace: String,
        targetNameSpace: String
    ) {
        sourceFile.copyTo(targetFile)
    }

}