let fs = require("fs") let config = require("./config.json") let http = require('https'); let archiver = require('archiver') var download = function(url, dest, cb) { var file = fs.createWriteStream(dest); http.get(url, function(response) { response.pipe(file); file.on('finish', function() { file.close(cb); }); }); } async function downloadAsync(url, path) { let p = new Promise((resolve, reject) => { download(url, path, resolve) }); await p } function reformatJsonFile(path) { fs.writeFileSync(path, JSON.stringify(JSON.parse(fs.readFileSync(path)), 0, 4)) } async function downloadAll() { await downloadAsync(`https://launchermeta.mojang.com/mc/game/version_manifest.json`, `./data/versions.json`) const versions = require("./data/versions.json") reformatJsonFile("./data/versions.json") const version = versions.versions.find((item) => { return item.id == config.version}) let path = `./data/${config.version}.json` await downloadAsync(version.url, path) reformatJsonFile(path) let game = JSON.parse(fs.readFileSync(path)) await downloadAsync(game.downloads.client.url, `./data/${config.version}.jar`) await downloadAsync(game.downloads.client_mappings.url, `./data/${config.version}.txt`) const output = fs.createWriteStream(`./data/${config.version}-Dummy.jar`) const archive = archiver('zip', { zlib: { level: 9 } }) archive.finalize() } downloadAll()