mirror of
https://github.com/artegoser/pimi-launcher-core.git
synced 2024-11-22 12:16:21 +03:00
Fixed audio for older MC versions not downloading. Made Readme better
This commit is contained in:
parent
b21ddf1d63
commit
f5e5482c5d
4 changed files with 32 additions and 47 deletions
32
README.md
32
README.md
|
@ -26,16 +26,6 @@ launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
memory: {
|
memory: {
|
||||||
max: "3000",
|
max: "3000",
|
||||||
min: "1000"
|
min: "1000"
|
||||||
},
|
|
||||||
server: {
|
|
||||||
host: "server.url",
|
|
||||||
port: "25565"
|
|
||||||
},
|
|
||||||
proxy: {
|
|
||||||
host: "proxy.url",
|
|
||||||
port: "8080",
|
|
||||||
username: "username",
|
|
||||||
password: "password"
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -53,7 +43,9 @@ launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
| `options.version.number` | String | Minecraft version that is going to be launched. | True |
|
| `options.version.number` | String | Minecraft version that is going to be launched. | True |
|
||||||
| `options.version.type` | String | Any string. The actual Minecraft launcher uses `release` and `snapshot`. | True |
|
| `options.version.type` | String | Any string. The actual Minecraft launcher uses `release` and `snapshot`. | True |
|
||||||
| `options.memory.max` | String | Max amount of memory being used by Minectaft | True |
|
| `options.memory.max` | String | Max amount of memory being used by Minectaft | True |
|
||||||
|
| `options.memory.min` | String | Min amount of memory being used by Minectaft | True |
|
||||||
| `options.forge.path` | String | Path to Universal Forge Jar | False |
|
| `options.forge.path` | String | Path to Universal Forge Jar | False |
|
||||||
|
| `options.customArgs` | String | Array of custom JVM options | False |
|
||||||
| `options.server.host` | String | Host url to the server, don't include the port | False |
|
| `options.server.host` | String | Host url to the server, don't include the port | False |
|
||||||
| `options.server.port` | String | Port of the host url, will default to `25565` if not entered. | False |
|
| `options.server.port` | String | Port of the host url, will default to `25565` if not entered. | False |
|
||||||
| `options.proxy.host` | String | Host url to the proxy, don't include the port | False |
|
| `options.proxy.host` | String | Host url to the proxy, don't include the port | False |
|
||||||
|
@ -130,16 +122,6 @@ launcher.core({
|
||||||
memory: {
|
memory: {
|
||||||
max: "500",
|
max: "500",
|
||||||
min: "100"
|
min: "100"
|
||||||
},
|
|
||||||
server: {
|
|
||||||
host: "server.url",
|
|
||||||
port: "25565"
|
|
||||||
},
|
|
||||||
proxy: {
|
|
||||||
host: "proxy.url",
|
|
||||||
port: "8080",
|
|
||||||
username: "username",
|
|
||||||
password: "password"
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
@ -163,16 +145,6 @@ launcher.authenticator.getAuth("email", "password").then(auth => {
|
||||||
memory: {
|
memory: {
|
||||||
max: "500",
|
max: "500",
|
||||||
min: "100"
|
min: "100"
|
||||||
},
|
|
||||||
server: {
|
|
||||||
host: "server.url",
|
|
||||||
port: "25565"
|
|
||||||
},
|
|
||||||
proxy: {
|
|
||||||
host: "proxy.url",
|
|
||||||
port: "8080",
|
|
||||||
username: "username",
|
|
||||||
password: "password"
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -81,7 +81,6 @@ module.exports.getAssets = function (directory, version) {
|
||||||
return new Promise(async(resolve) => {
|
return new Promise(async(resolve) => {
|
||||||
const assetsUrl = 'https://resources.download.minecraft.net';
|
const assetsUrl = 'https://resources.download.minecraft.net';
|
||||||
const failed = [];
|
const failed = [];
|
||||||
const parseVersion = version.assetIndex.id.split('.');
|
|
||||||
|
|
||||||
if(!fs.existsSync(path.join(directory, 'assets', 'indexes', `${version.assetIndex.id}.json`))) {
|
if(!fs.existsSync(path.join(directory, 'assets', 'indexes', `${version.assetIndex.id}.json`))) {
|
||||||
await downloadAsync(version.assetIndex.url, path.join(directory, 'assets', 'indexes'), `${version.assetIndex.id}.json`);
|
await downloadAsync(version.assetIndex.url, path.join(directory, 'assets', 'indexes'), `${version.assetIndex.id}.json`);
|
||||||
|
@ -98,16 +97,6 @@ module.exports.getAssets = function (directory, version) {
|
||||||
const download = await downloadAsync(`${assetsUrl}/${subhash}/${hash}`, assetDirectory, hash);
|
const download = await downloadAsync(`${assetsUrl}/${subhash}/${hash}`, assetDirectory, hash);
|
||||||
|
|
||||||
if(download.failed) failed.push(download.asset);
|
if(download.failed) failed.push(download.asset);
|
||||||
|
|
||||||
if(parseVersion[1] < 8 && parseVersion[2] < 3) {
|
|
||||||
let legacyAsset = asset.split('/')
|
|
||||||
legacyAsset.pop()
|
|
||||||
|
|
||||||
if(!fs.existsSync(path.join(directory, 'assets', 'legacy', legacyAsset.join('/')))) {
|
|
||||||
shelljs.mkdir('-p', path.join(directory, 'assets', 'legacy', legacyAsset.join('/')));
|
|
||||||
fs.copyFileSync(path.join(assetDirectory, hash), path.join(directory, 'assets', 'legacy', asset))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +105,26 @@ module.exports.getAssets = function (directory, version) {
|
||||||
for (const fail of failed) await downloadAsync(fail.url, fail.directory, fail.name);
|
for (const fail of failed) await downloadAsync(fail.url, fail.directory, fail.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seems taking it out of the initial download loop allows everything to be copied...
|
||||||
|
if(version.assets === "legacy") {
|
||||||
|
for(const asset in index.objects) {
|
||||||
|
const hash = index.objects[asset].hash;
|
||||||
|
const subhash = hash.substring(0,2);
|
||||||
|
const assetDirectory = path.join(directory, 'assets', 'objects', subhash);
|
||||||
|
|
||||||
|
let legacyAsset = asset.split('/');
|
||||||
|
legacyAsset.pop();
|
||||||
|
|
||||||
|
if(!fs.existsSync(path.join(directory, 'assets', 'legacy', legacyAsset.join('/')))) {
|
||||||
|
shelljs.mkdir('-p', path.join(directory, 'assets', 'legacy', legacyAsset.join('/')));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!fs.existsSync(path.join(assetDirectory, hash), path.join(directory, 'assets', 'legacy', asset))) {
|
||||||
|
fs.copyFileSync(path.join(assetDirectory, hash), path.join(directory, 'assets', 'legacy', asset))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -139,7 +148,12 @@ module.exports.getNatives = function (root, version, os) {
|
||||||
if (native) {
|
if (native) {
|
||||||
const name = native.path.split('/').pop();
|
const name = native.path.split('/').pop();
|
||||||
await downloadAsync(native.url, nativeDirectory, name);
|
await downloadAsync(native.url, nativeDirectory, name);
|
||||||
new zip(path.join(nativeDirectory, name)).extractAllTo(nativeDirectory, true);
|
try {new zip(path.join(nativeDirectory, name)).extractAllTo(nativeDirectory, true);} catch(e) {
|
||||||
|
// Only doing a console.warn since a stupid error happens. You can basically ignore this.
|
||||||
|
// if it says Invalid file name, just means two files were downloaded and both were deleted.
|
||||||
|
// All is well.
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
shelljs.rm(path.join(nativeDirectory, name));
|
shelljs.rm(path.join(nativeDirectory, name));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -228,10 +242,9 @@ module.exports.getClasses = function (root, version) {
|
||||||
|
|
||||||
module.exports.getLaunchOptions = function (version, forge, options) {
|
module.exports.getLaunchOptions = function (version, forge, options) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const parseVersion = version.assetIndex.id.split('.');
|
|
||||||
const type = forge || version;
|
const type = forge || version;
|
||||||
const arguments = type.minecraftArguments ? type.minecraftArguments.split(' ') : type.arguments.game;
|
const arguments = type.minecraftArguments ? type.minecraftArguments.split(' ') : type.arguments.game;
|
||||||
const assetPath = parseVersion[1] < 8 && parseVersion[2] < 3 ? path.join(options.root, 'assets', 'legacy') : path.join(options.root, 'assets');
|
const assetPath = version.assets === "legacy" ? path.join(options.root, 'assets', 'legacy') : path.join(options.root, 'assets');
|
||||||
|
|
||||||
const fields = {
|
const fields = {
|
||||||
'${auth_access_token}': options.authorization.access_token,
|
'${auth_access_token}': options.authorization.access_token,
|
||||||
|
@ -244,6 +257,7 @@ module.exports.getLaunchOptions = function (version, forge, options) {
|
||||||
'${assets_index_name}': version.assetIndex.id,
|
'${assets_index_name}': version.assetIndex.id,
|
||||||
'${game_directory}': path.join(options.root),
|
'${game_directory}': path.join(options.root),
|
||||||
'${assets_root}': assetPath,
|
'${assets_root}': assetPath,
|
||||||
|
'${game_assets}': assetPath,
|
||||||
'${version_type}': options.version.type
|
'${version_type}': options.version.type
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,7 @@ module.exports = async function (options) {
|
||||||
await handler.getAssets(options.root, versionFile);
|
await handler.getAssets(options.root, versionFile);
|
||||||
|
|
||||||
// Launch options. Thank you Lyrus for the reformat <3
|
// Launch options. Thank you Lyrus for the reformat <3
|
||||||
let launchOptions;
|
const launchOptions = await handler.getLaunchOptions(versionFile, forge ? forge.forge : null, options);
|
||||||
launchOptions = await handler.getLaunchOptions(versionFile, forge ? forge.forge : null, options);
|
|
||||||
|
|
||||||
const launchArguments = args.concat(jvm, classPaths, launchOptions);
|
const launchArguments = args.concat(jvm, classPaths, launchOptions);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "minecraft-launcher-core",
|
"name": "minecraft-launcher-core",
|
||||||
"version": "2.4.0",
|
"version": "2.4.1",
|
||||||
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
|
"description": "Module that downloads Minecraft assets and runs Minecraft. Also Supports Forge",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue