Skip to content

Commit

Permalink
fixed forge json profiles list from 404
Browse files Browse the repository at this point in the history
  • Loading branch information
hexparrot committed Apr 23, 2021
1 parent 2cd410a commit 603d9c5
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ exports.profile_manifests = {
forge: {
name: 'Forge Mod',
request_args: {
url: 'http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions.json',
url: 'http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json',
json: true
},
handler: function(profile_dir, body, callback) {
Expand All @@ -233,33 +233,40 @@ exports.profile_manifests = {
try {
for (var index in body.promos) {
var item = new profile_template();
var ref_obj = body.promos[index];
var mcver = index.split('-')[0];
var forgever = body.promos[index];

item['id'] = index;
item['time'] = ref_obj['modified'];
item['releaseTime'] = ref_obj['modified'];
item['type'] = 'release';
item['group'] = 'forge';
item['webui_desc'] = 'Forge Jar (build {0})'.format(ref_obj['build']);
item['webui_desc'] = 'Forge Jar (build {0})'.format(forgever);
item['weight'] = 0;
if (ref_obj['branch'])
item['filename'] = 'forge-{0}-{1}-{2}-installer.jar'.format(ref_obj['mcversion'], ref_obj['version'], ref_obj['branch']);
else
item['filename'] = 'forge-{0}-{1}-installer.jar'.format(ref_obj['mcversion'], ref_obj['version']);
item['downloaded'] = fs.existsSync(path.join(profile_dir, item.id, item.filename));
item['version'] = ref_obj['mcversion'];
item['release_version'] = ref_obj['version'];
if (ref_obj['branch'])
item['url'] = 'http://files.minecraftforge.net/maven/net/minecraftforge/forge/{0}-{1}-{2}/{3}'.format(ref_obj['mcversion'], ref_obj['version'], ref_obj['branch'], item['filename']);
else
item['url'] = 'http://files.minecraftforge.net/maven/net/minecraftforge/forge/{0}-{1}/{2}'.format(ref_obj['mcversion'], ref_obj['version'], item['filename']);
item['version'] = index;
item['release_version'] = forgever;

var ver = ref_obj['mcversion'].match(/(\d+)\.(\d+)\.?(\d+)?/);
var ver = mcver.match(/(\d+)\.(\d+)\.?(\d+)?/);

if (parseInt(ver[1]) >= 1 && parseInt(ver[2]) >= 6)
p.push(item); // 1.x major, .6 minor, chosen because 1.6.1 changed the installation process so drastically
if (parseInt(ver[1]) <= 1 && parseInt(ver[2]) <= 5) {
// skip version 1.5.2 and earlier--non installer.jar model not supported workflow
} else if (mcver == '1.10') {
// 1.x major, .10 minor but not .10.2, chosen because url construction
item['filename'] = 'forge-{0}-{1}-{0}-installer.jar'.format(mcver, forgever);
item['url'] = 'http://maven.minecraftforge.net/net/minecraftforge/forge/1.10-{0}-1.10.0/forge-1.10-{0}-1.10.0-installer.jar'.format(forgever);
item['downloaded'] = fs.existsSync(path.join(profile_dir, item.id, item.filename));
p.push(item);
} else if (parseInt(ver[1]) == 1 && parseInt(ver[2]) >= 7 && parseInt(ver[2]) <= 9) {
// 1.x major, .7-.9 minor, chosen because url construction
item['filename'] = 'forge-{0}-{1}-{0}-installer.jar'.format(mcver, forgever);
item['url'] = 'http://files.minecraftforge.net/maven/net/minecraftforge/forge/{0}-{1}-{0}/{2}'.format(mcver, forgever, item['filename']);
item['downloaded'] = fs.existsSync(path.join(profile_dir, item.id, item.filename));
p.push(item);
} else {
item['filename'] = 'forge-{0}-{1}-installer.jar'.format(mcver, forgever);
item['url'] = 'http://files.minecraftforge.net/maven/net/minecraftforge/forge/{0}-{1}/{2}'.format(mcver, forgever, item['filename']);
item['downloaded'] = fs.existsSync(path.join(profile_dir, item.id, item.filename));
p.push(item);
}
}

} catch (e) {}

callback(null, p);
Expand Down

0 comments on commit 603d9c5

Please sign in to comment.