-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ugh... I'm not sure if I want to do this.
- Loading branch information
Showing
5 changed files
with
73 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
maven { | ||
name = 'Fabric' | ||
url = 'https://maven.fabricmc.net/' | ||
} | ||
} | ||
|
||
dependencies { | ||
classpath ("net.fabricmc:mapping-io:${project.mappingio_version}") | ||
classpath ('com.google.code.gson:gson:2.10.1') | ||
} | ||
} | ||
|
||
|
||
import com.google.gson.JsonElement | ||
import com.google.gson.JsonObject | ||
import com.google.gson.JsonParser | ||
import net.fabricmc.mappingio.MappingReader | ||
import net.fabricmc.mappingio.MappingWriter | ||
import net.fabricmc.mappingio.adapter.MappingSourceNsSwitch | ||
import net.fabricmc.mappingio.format.MappingFormat | ||
import net.fabricmc.mappingio.tree.MemoryMappingTree | ||
|
||
import java.nio.file.Files | ||
import java.util.zip.DeflaterOutputStream | ||
|
||
ext.MANIFEST_URL = new URL("https://launchermeta.mojang.com/mc/game/version_manifest_v2.json") | ||
|
||
tasks.register("downloadCommanderMappings") { | ||
File processed = new File("${project.layout.projectDirectory.getAsFile()}/.gradle/downloadCommanderMappings/${project.minecraft_version}/processed.bin") | ||
if (!processed.exists()) { | ||
Files.createDirectories(processed.toPath().getParent()) | ||
|
||
MemoryMappingTree tree = new MemoryMappingTree() | ||
MappingReader.read(new InputStreamReader(new URL(getManifest().getAsJsonObject("downloads").getAsJsonObject("client_mappings").get("url").getAsString()).openStream()), new MappingSourceNsSwitch(tree, "target", true)) | ||
tree.setSrcNamespace("official") | ||
tree.setDstNamespaces(List.of("mojang")) | ||
|
||
OutputStream stream = Files.newOutputStream(processed.toPath()) | ||
tree.accept(MappingWriter.create(new OutputStreamWriter(new DeflaterOutputStream(stream)), MappingFormat.TINY_FILE)) | ||
} | ||
} | ||
|
||
processResources { | ||
mustRunAfter(tasks.downloadCommanderMappings) | ||
from(new File("${project.layout.projectDirectory.getAsFile()}/.gradle/downloadCommanderMappings/${project.minecraft_version}/processed.bin")) { | ||
rename { "commander/mappings/processed.bin" } | ||
} | ||
} | ||
|
||
JsonObject getManifest() { | ||
var o = downloadObject(ext.MANIFEST_URL) | ||
for (JsonElement versions : o.getAsJsonArray("versions")) { | ||
if (project.minecraft_version == versions.getAsJsonObject().get("id").getAsString()) { | ||
return downloadObject(new URL(versions.getAsJsonObject().get("url").getAsString())) | ||
} | ||
} | ||
throw new IllegalStateException("Unknown version '%s'".formatted(project.minecraft_version)) | ||
} | ||
|
||
static JsonObject downloadObject(URL url) { | ||
return JsonParser.parseReader(new InputStreamReader(url.openStream())).getAsJsonObject() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 0 additions & 61 deletions
61
src/main/java/me/melontini/commander/impl/util/mappings/MinecraftDownloader.java
This file was deleted.
Oops, something went wrong.