mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 03:32:12 -08:00
Use launchermeta.mojang.com instead of S3 (deprecated). (#12)
The deprecated endpoint will be removed by the end of 2018.
This commit is contained in:
parent
86c7245c41
commit
f089993ea4
@ -1005,12 +1005,11 @@ class AssetGuard extends EventEmitter {
|
||||
*/
|
||||
loadVersionData(version, force = false){
|
||||
const self = this
|
||||
return new Promise((resolve, reject) => {
|
||||
const name = version + '.json'
|
||||
const url = 'https://s3.amazonaws.com/Minecraft.Download/versions/' + version + '/' + name
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const versionPath = path.join(self.commonPath, 'versions', version)
|
||||
const versionFile = path.join(versionPath, name)
|
||||
const versionFile = path.join(versionPath, version + '.json')
|
||||
if(!fs.existsSync(versionFile) || force){
|
||||
const url = await self._getVersionDataUrl(version)
|
||||
//This download will never be tracked as it's essential and trivial.
|
||||
console.log('Preparing download of ' + version + ' assets.')
|
||||
mkpath.sync(versionPath)
|
||||
@ -1024,6 +1023,34 @@ class AssetGuard extends EventEmitter {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses Mojang's version manifest and retrieves the url of the version
|
||||
* data index.
|
||||
*
|
||||
* @param {string} version The version to lookup.
|
||||
* @returns {Promise.<string>} Promise which resolves to the url of the version data index.
|
||||
* If the version could not be found, resolves to null.
|
||||
*/
|
||||
_getVersionDataUrl(version){
|
||||
return new Promise((resolve, reject) => {
|
||||
request('https://launchermeta.mojang.com/mc/game/version_manifest.json', (error, resp, body) => {
|
||||
if(error){
|
||||
reject(error)
|
||||
} else {
|
||||
const manifest = JSON.parse(body)
|
||||
|
||||
for(let v of manifest.versions){
|
||||
if(v.id === version){
|
||||
resolve(v.url)
|
||||
}
|
||||
}
|
||||
|
||||
resolve(null)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// Asset (Category=''') Validation Functions
|
||||
// #region
|
||||
|
Loading…
Reference in New Issue
Block a user