Verschiedenes
This commit is contained in:
parent
46853157ec
commit
a7ce59f4b5
@ -1,3 +1,4 @@
|
||||
|
||||
// Requirements
|
||||
const AdmZip = require('adm-zip')
|
||||
const async = require('async')
|
||||
@ -1485,7 +1486,7 @@ class AssetGuard extends EventEmitter {
|
||||
* @param {string} server The Server to load Forge data for.
|
||||
* @returns {Promise.<Object>} A promise which resolves to Forge's version.json data.
|
||||
*/
|
||||
loadForgeData(server){
|
||||
/* loadForgeData(server){
|
||||
const self = this
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const modules = server.getModules()
|
||||
@ -1518,7 +1519,7 @@ class AssetGuard extends EventEmitter {
|
||||
}
|
||||
reject('No forge module found!')
|
||||
})
|
||||
}
|
||||
} */
|
||||
|
||||
_parseForgeLibraries(){
|
||||
/* TODO
|
||||
@ -1882,17 +1883,14 @@ class AssetGuard extends EventEmitter {
|
||||
this.emit('validate', 'files')
|
||||
await this.processDlQueues()
|
||||
//this.emit('complete', 'download')
|
||||
const forgeData = await this.loadForgeData(server)
|
||||
|
||||
|
||||
return {
|
||||
versionData,
|
||||
forgeData
|
||||
versionData
|
||||
}
|
||||
|
||||
} catch (err){
|
||||
return {
|
||||
versionData: null,
|
||||
forgeData: null,
|
||||
error: err
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ const logger = require('./loggerutil')('%c[ConfigManager]', 'color: #a02d2a; fon
|
||||
|
||||
const sysRoot = process.env.APPDATA || (process.platform == 'darwin' ? process.env.HOME + '/Library/Application Support' : process.env.HOME)
|
||||
// TODO change
|
||||
const dataPath = path.join(sysRoot, '.helioslauncher')
|
||||
const dataPath = path.join(sysRoot, '.nexuslauncher')
|
||||
|
||||
// Forked processes do not have access to electron, so we have this workaround.
|
||||
const launcherDir = process.env.CONFIG_DIRECT_PATH || require('electron').remote.app.getPath('userData')
|
||||
@ -206,7 +206,7 @@ exports.isFirstLaunch = function(){
|
||||
* @returns {string} The name of the folder.
|
||||
*/
|
||||
exports.getTempNativeFolder = function(){
|
||||
return 'WCNatives'
|
||||
return 'NexusNatives'
|
||||
}
|
||||
|
||||
// System Settings (Unconfigurable on UI)
|
||||
|
@ -406,6 +406,14 @@ class Server {
|
||||
return this.autoconnect
|
||||
}
|
||||
|
||||
getOptifineVersion(){
|
||||
return this.optifineVersion
|
||||
}
|
||||
|
||||
getLaunchWrapperVersion(){
|
||||
return this.launchWrapperVersion
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Array.<Module>} An array of modules for this server.
|
||||
*/
|
||||
@ -482,6 +490,8 @@ class DistroIndex {
|
||||
return this.servers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a server configuration by its ID. If it does not
|
||||
* exist, null will be returned.
|
||||
@ -537,7 +547,7 @@ exports.pullRemote = function(){
|
||||
return exports.pullLocal()
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
const distroURL = 'http://mc.westeroscraft.com/WesterosCraftLauncher/distribution.json'
|
||||
const distroURL = 'http://ChickenDevLab.github.io/NexusLauncher/data/distribution.json'
|
||||
//const distroURL = 'https://gist.githubusercontent.com/dscalzi/53b1ba7a11d26a5c353f9d5ae484b71b/raw/'
|
||||
const opts = {
|
||||
url: distroURL,
|
||||
|
@ -1,70 +1,67 @@
|
||||
const AdmZip = require('adm-zip')
|
||||
const child_process = require('child_process')
|
||||
const crypto = require('crypto')
|
||||
const fs = require('fs-extra')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const { URL } = require('url')
|
||||
const AdmZip = require('adm-zip')
|
||||
const child_process = require('child_process')
|
||||
const crypto = require('crypto')
|
||||
const fs = require('fs-extra')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const { URL } = require('url')
|
||||
|
||||
const { Util, Library } = require('./assetguard')
|
||||
const ConfigManager = require('./configmanager')
|
||||
const DistroManager = require('./distromanager')
|
||||
const LoggerUtil = require('./loggerutil')
|
||||
const { Library } = require('./assetguard')
|
||||
const ConfigManager = require('./configmanager')
|
||||
const DistroManager = require('./distromanager')
|
||||
const LoggerUtil = require('./loggerutil')
|
||||
|
||||
const logger = LoggerUtil('%c[ProcessBuilder]', 'color: #003996; font-weight: bold')
|
||||
|
||||
class ProcessBuilder {
|
||||
|
||||
constructor(distroServer, versionData, forgeData, authUser, launcherVersion){
|
||||
constructor(distroServer, versionData, authUser, launcherVersion) {
|
||||
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.getID())
|
||||
this.commonDir = ConfigManager.getCommonDirectory()
|
||||
this.server = distroServer
|
||||
this.versionData = versionData
|
||||
this.forgeData = forgeData
|
||||
this.authUser = authUser
|
||||
this.launcherVersion = launcherVersion
|
||||
this.fmlDir = path.join(this.gameDir, 'forgeModList.json')
|
||||
this.llDir = path.join(this.gameDir, 'liteloaderModList.json')
|
||||
this.libPath = path.join(this.commonDir, 'libraries')
|
||||
|
||||
this.usingLiteLoader = false
|
||||
this.llPath = null
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convienence method to run the functions typically used to build a process.
|
||||
*/
|
||||
build(){
|
||||
build() {
|
||||
fs.ensureDirSync(this.gameDir)
|
||||
const tempNativePath = path.join(os.tmpdir(), ConfigManager.getTempNativeFolder(), crypto.pseudoRandomBytes(16).toString('hex'))
|
||||
process.throwDeprecation = true
|
||||
this.setupLiteLoader()
|
||||
logger.log('Using liteloader:', this.usingLiteLoader)
|
||||
const modObj = this.resolveModConfiguration(ConfigManager.getModConfiguration(this.server.getID()).mods, this.server.getModules())
|
||||
|
||||
// Mod list below 1.13
|
||||
if(!Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
||||
this.constructModList('forge', modObj.fMods, true)
|
||||
if(this.usingLiteLoader){
|
||||
this.constructModList('liteloader', modObj.lMods, true)
|
||||
}
|
||||
}
|
||||
|
||||
const uberModArr = modObj.fMods.concat(modObj.lMods)
|
||||
let args = this.constructJVMArguments(uberModArr, tempNativePath)
|
||||
|
||||
if(Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
||||
args = args.concat(this.constructModArguments(modObj.fMods))
|
||||
}
|
||||
|
||||
|
||||
let args = this.constructJVMArguments(tempNativePath)
|
||||
|
||||
|
||||
logger.log('Launch Arguments:', args)
|
||||
let exists = false
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (args[i] == '--tweakClass') {
|
||||
args[i + 1] = 'optifine.OptiFineTweaker'
|
||||
exists = true
|
||||
}
|
||||
}
|
||||
if (!exists) {
|
||||
args.push('--tweakClass')
|
||||
args.push('optifine.OptiFineTweaker')
|
||||
}
|
||||
|
||||
const child = child_process.spawn(ConfigManager.getJavaExecutable(), args, {
|
||||
cwd: this.gameDir,
|
||||
detached: ConfigManager.getLaunchDetached()
|
||||
})
|
||||
|
||||
if(ConfigManager.getLaunchDetached()){
|
||||
if (ConfigManager.getLaunchDetached()) {
|
||||
child.unref()
|
||||
}
|
||||
|
||||
@ -83,7 +80,7 @@ class ProcessBuilder {
|
||||
child.on('close', (code, signal) => {
|
||||
logger.log('Exited with code', code)
|
||||
fs.remove(tempNativePath, (err) => {
|
||||
if(err){
|
||||
if (err) {
|
||||
logger.warn('Error while deleting temp dir', err)
|
||||
} else {
|
||||
logger.log('Temp dir deleted successfully.')
|
||||
@ -111,7 +108,7 @@ class ProcessBuilder {
|
||||
* @param {Object} required Optional. The required object from the mod's distro declaration.
|
||||
* @returns {boolean} True if the mod is enabled, false otherwise.
|
||||
*/
|
||||
static isModEnabled(modCfg, required = null){
|
||||
static isModEnabled(modCfg, required = null) {
|
||||
return modCfg != null ? ((typeof modCfg === 'boolean' && modCfg) || (typeof modCfg === 'object' && (typeof modCfg.value !== 'undefined' ? modCfg.value : true))) : required != null ? required.isDefault() : true
|
||||
}
|
||||
|
||||
@ -121,19 +118,19 @@ class ProcessBuilder {
|
||||
* launch options. Note that liteloader is only allowed as a top level
|
||||
* mod. It must not be declared as a submodule.
|
||||
*/
|
||||
setupLiteLoader(){
|
||||
for(let ll of this.server.getModules()){
|
||||
if(ll.getType() === DistroManager.Types.LiteLoader){
|
||||
if(!ll.getRequired().isRequired()){
|
||||
setupLiteLoader() {
|
||||
for (let ll of this.server.getModules()) {
|
||||
if (ll.getType() === DistroManager.Types.LiteLoader) {
|
||||
if (!ll.getRequired().isRequired()) {
|
||||
const modCfg = ConfigManager.getModConfiguration(this.server.getID()).mods
|
||||
if(ProcessBuilder.isModEnabled(modCfg[ll.getVersionlessID()], ll.getRequired())){
|
||||
if(fs.existsSync(ll.getArtifact().getPath())){
|
||||
if (ProcessBuilder.isModEnabled(modCfg[ll.getVersionlessID()], ll.getRequired())) {
|
||||
if (fs.existsSync(ll.getArtifact().getPath())) {
|
||||
this.usingLiteLoader = true
|
||||
this.llPath = ll.getArtifact().getPath()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(fs.existsSync(ll.getArtifact().getPath())){
|
||||
if (fs.existsSync(ll.getArtifact().getPath())) {
|
||||
this.usingLiteLoader = true
|
||||
this.llPath = ll.getArtifact().getPath()
|
||||
}
|
||||
@ -151,71 +148,9 @@ class ProcessBuilder {
|
||||
* @returns {{fMods: Array.<Object>, lMods: Array.<Object>}} An object which contains
|
||||
* a list of enabled forge mods and litemods.
|
||||
*/
|
||||
resolveModConfiguration(modCfg, mdls){
|
||||
let fMods = []
|
||||
let lMods = []
|
||||
|
||||
for(let mdl of mdls){
|
||||
const type = mdl.getType()
|
||||
if(type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader){
|
||||
const o = !mdl.getRequired().isRequired()
|
||||
const e = ProcessBuilder.isModEnabled(modCfg[mdl.getVersionlessID()], mdl.getRequired())
|
||||
if(!o || (o && e)){
|
||||
if(mdl.hasSubModules()){
|
||||
const v = this.resolveModConfiguration(modCfg[mdl.getVersionlessID()].mods, mdl.getSubModules())
|
||||
fMods = fMods.concat(v.fMods)
|
||||
lMods = lMods.concat(v.lMods)
|
||||
if(mdl.type === DistroManager.Types.LiteLoader){
|
||||
continue
|
||||
}
|
||||
}
|
||||
if(mdl.type === DistroManager.Types.ForgeMod){
|
||||
fMods.push(mdl)
|
||||
} else {
|
||||
lMods.push(mdl)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
fMods,
|
||||
lMods
|
||||
}
|
||||
}
|
||||
|
||||
_lteMinorVersion(version) {
|
||||
return Number(this.forgeData.id.split('-')[0].split('.')[1]) <= Number(version)
|
||||
}
|
||||
|
||||
/**
|
||||
* Test to see if this version of forge requires the absolute: prefix
|
||||
* on the modListFile repository field.
|
||||
*/
|
||||
_requiresAbsolute(){
|
||||
try {
|
||||
if(this._lteMinorVersion(9)) {
|
||||
return false
|
||||
}
|
||||
const ver = this.forgeData.id.split('-')[2]
|
||||
const pts = ver.split('.')
|
||||
const min = [14, 23, 3, 2655]
|
||||
for(let i=0; i<pts.length; i++){
|
||||
const parsed = Number.parseInt(pts[i])
|
||||
if(parsed < min[i]){
|
||||
return false
|
||||
} else if(parsed > min[i]){
|
||||
return true
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// We know old forge versions follow this format.
|
||||
// Error must be caused by newer version.
|
||||
}
|
||||
|
||||
// Equal or errored
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a mod list json object.
|
||||
@ -224,60 +159,14 @@ class ProcessBuilder {
|
||||
* @param {Array.<Object>} mods An array of mods to add to the mod list.
|
||||
* @param {boolean} save Optional. Whether or not we should save the mod list file.
|
||||
*/
|
||||
constructModList(type, mods, save = false){
|
||||
const modList = {
|
||||
repositoryRoot: ((type === 'forge' && this._requiresAbsolute()) ? 'absolute:' : '') + path.join(this.commonDir, 'modstore')
|
||||
}
|
||||
|
||||
const ids = []
|
||||
if(type === 'forge'){
|
||||
for(let mod of mods){
|
||||
ids.push(mod.getExtensionlessID())
|
||||
}
|
||||
} else {
|
||||
for(let mod of mods){
|
||||
ids.push(mod.getExtensionlessID() + '@' + mod.getExtension())
|
||||
}
|
||||
}
|
||||
modList.modRef = ids
|
||||
|
||||
if(save){
|
||||
const json = JSON.stringify(modList, null, 4)
|
||||
fs.writeFileSync(type === 'forge' ? this.fmlDir : this.llDir, json, 'UTF-8')
|
||||
}
|
||||
|
||||
return modList
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the mod argument list for forge 1.13
|
||||
*
|
||||
* @param {Array.<Object>} mods An array of mods to add to the mod list.
|
||||
*/
|
||||
constructModArguments(mods){
|
||||
const argStr = mods.map(mod => {
|
||||
return mod.getExtensionlessID()
|
||||
}).join(',')
|
||||
|
||||
if(argStr){
|
||||
return [
|
||||
'--fml.mavenRoots',
|
||||
path.join('..', '..', 'common', 'modstore'),
|
||||
'--fml.mods',
|
||||
argStr
|
||||
]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_processAutoConnectArg(args){
|
||||
if(ConfigManager.getAutoConnect() && this.server.isAutoConnect()){
|
||||
_processAutoConnectArg(args) {
|
||||
if (ConfigManager.getAutoConnect() && this.server.isAutoConnect()) {
|
||||
const serverURL = new URL('my://' + this.server.getAddress())
|
||||
args.push('--server')
|
||||
args.push(serverURL.hostname)
|
||||
if(serverURL.port){
|
||||
if (serverURL.port) {
|
||||
args.push('--port')
|
||||
args.push(serverURL.port)
|
||||
}
|
||||
@ -291,47 +180,10 @@ class ProcessBuilder {
|
||||
* @param {string} tempNativePath The path to store the native libraries.
|
||||
* @returns {Array.<string>} An array containing the full JVM arguments for this process.
|
||||
*/
|
||||
constructJVMArguments(mods, tempNativePath){
|
||||
if(Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
||||
return this._constructJVMArguments113(mods, tempNativePath)
|
||||
} else {
|
||||
return this._constructJVMArguments112(mods, tempNativePath)
|
||||
}
|
||||
}
|
||||
constructJVMArguments(tempNativePath) {
|
||||
|
||||
/**
|
||||
* Construct the argument array that will be passed to the JVM process.
|
||||
* This function is for 1.12 and below.
|
||||
*
|
||||
* @param {Array.<Object>} mods An array of enabled mods which will be launched with this process.
|
||||
* @param {string} tempNativePath The path to store the native libraries.
|
||||
* @returns {Array.<string>} An array containing the full JVM arguments for this process.
|
||||
*/
|
||||
_constructJVMArguments112(mods, tempNativePath){
|
||||
return this._constructJVMArguments113(tempNativePath)
|
||||
|
||||
let args = []
|
||||
|
||||
// Classpath Argument
|
||||
args.push('-cp')
|
||||
args.push(this.classpathArg(mods, tempNativePath).join(process.platform === 'win32' ? ';' : ':'))
|
||||
|
||||
// Java Arguments
|
||||
if(process.platform === 'darwin'){
|
||||
args.push('-Xdock:name=HeliosLauncher')
|
||||
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
||||
}
|
||||
args.push('-Xmx' + ConfigManager.getMaxRAM())
|
||||
args.push('-Xms' + ConfigManager.getMinRAM())
|
||||
args = args.concat(ConfigManager.getJVMOptions())
|
||||
args.push('-Djava.library.path=' + tempNativePath)
|
||||
|
||||
// Main Java Class
|
||||
args.push(this.forgeData.mainClass)
|
||||
|
||||
// Forge Arguments
|
||||
args = args.concat(this._resolveForgeArgs())
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
/**
|
||||
@ -344,7 +196,7 @@ class ProcessBuilder {
|
||||
* @param {string} tempNativePath The path to store the native libraries.
|
||||
* @returns {Array.<string>} An array containing the full JVM arguments for this process.
|
||||
*/
|
||||
_constructJVMArguments113(mods, tempNativePath){
|
||||
_constructJVMArguments113(tempNativePath) {
|
||||
|
||||
const argDiscovery = /\${*(.*)}/
|
||||
|
||||
@ -354,8 +206,8 @@ class ProcessBuilder {
|
||||
//args.push('-Dlog4j.configurationFile=D:\\WesterosCraft\\game\\common\\assets\\log_configs\\client-1.12.xml')
|
||||
|
||||
// Java Arguments
|
||||
if(process.platform === 'darwin'){
|
||||
args.push('-Xdock:name=HeliosLauncher')
|
||||
if (process.platform === 'darwin') {
|
||||
args.push('-Xdock:name=NexusLauncher')
|
||||
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
||||
}
|
||||
args.push('-Xmx' + ConfigManager.getMaxRAM())
|
||||
@ -363,32 +215,32 @@ class ProcessBuilder {
|
||||
args = args.concat(ConfigManager.getJVMOptions())
|
||||
|
||||
// Main Java Class
|
||||
args.push(this.forgeData.mainClass)
|
||||
args.push('net.minecraft.launchwrapper.Launch')
|
||||
|
||||
// Vanilla Arguments
|
||||
args = args.concat(this.versionData.arguments.game)
|
||||
|
||||
for(let i=0; i<args.length; i++){
|
||||
if(typeof args[i] === 'object' && args[i].rules != null){
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
if (typeof args[i] === 'object' && args[i].rules != null) {
|
||||
|
||||
let checksum = 0
|
||||
for(let rule of args[i].rules){
|
||||
if(rule.os != null){
|
||||
if(rule.os.name === Library.mojangFriendlyOS()
|
||||
&& (rule.os.version == null || new RegExp(rule.os.version).test(os.release))){
|
||||
if(rule.action === 'allow'){
|
||||
for (let rule of args[i].rules) {
|
||||
if (rule.os != null) {
|
||||
if (rule.os.name === Library.mojangFriendlyOS()
|
||||
&& (rule.os.version == null || new RegExp(rule.os.version).test(os.release))) {
|
||||
if (rule.action === 'allow') {
|
||||
checksum++
|
||||
}
|
||||
} else {
|
||||
if(rule.action === 'disallow'){
|
||||
if (rule.action === 'disallow') {
|
||||
checksum++
|
||||
}
|
||||
}
|
||||
} else if(rule.features != null){
|
||||
} else if (rule.features != null) {
|
||||
// We don't have many 'features' in the index at the moment.
|
||||
// This should be fine for a while.
|
||||
if(rule.features.has_custom_resolution != null && rule.features.has_custom_resolution === true){
|
||||
if(ConfigManager.getFullscreen()){
|
||||
if (rule.features.has_custom_resolution != null && rule.features.has_custom_resolution === true) {
|
||||
if (ConfigManager.getFullscreen()) {
|
||||
args[i].value = [
|
||||
'--fullscreen',
|
||||
'true'
|
||||
@ -400,10 +252,10 @@ class ProcessBuilder {
|
||||
}
|
||||
|
||||
// TODO splice not push
|
||||
if(checksum === args[i].rules.length){
|
||||
if(typeof args[i].value === 'string'){
|
||||
if (checksum === args[i].rules.length) {
|
||||
if (typeof args[i].value === 'string') {
|
||||
args[i] = args[i].value
|
||||
} else if(typeof args[i].value === 'object'){
|
||||
} else if (typeof args[i].value === 'object') {
|
||||
//args = args.concat(args[i].value)
|
||||
args.splice(i, 1, ...args[i].value)
|
||||
}
|
||||
@ -414,11 +266,11 @@ class ProcessBuilder {
|
||||
args[i] = null
|
||||
}
|
||||
|
||||
} else if(typeof args[i] === 'string'){
|
||||
if(argDiscovery.test(args[i])){
|
||||
} else if (typeof args[i] === 'string') {
|
||||
if (argDiscovery.test(args[i])) {
|
||||
const identifier = args[i].match(argDiscovery)[1]
|
||||
let val = null
|
||||
switch(identifier){
|
||||
switch (identifier) {
|
||||
case 'auth_player_name':
|
||||
val = this.authUser.displayName.trim()
|
||||
break
|
||||
@ -463,36 +315,17 @@ class ProcessBuilder {
|
||||
val = args[i].replace(argDiscovery, this.launcherVersion)
|
||||
break
|
||||
case 'classpath':
|
||||
val = this.classpathArg(mods, tempNativePath).join(process.platform === 'win32' ? ';' : ':')
|
||||
val = this.classpathArg(tempNativePath).join(process.platform === 'win32' ? ';' : ':')
|
||||
break
|
||||
}
|
||||
if(val != null){
|
||||
if (val != null) {
|
||||
args[i] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Autoconnect
|
||||
let isAutoconnectBroken
|
||||
try {
|
||||
isAutoconnectBroken = Util.isAutoconnectBroken(this.forgeData.id.split('-')[2])
|
||||
} catch(err) {
|
||||
logger.error(err)
|
||||
logger.error('Forge version format changed.. assuming autoconnect works.')
|
||||
logger.debug('Forge version:', this.forgeData.id)
|
||||
}
|
||||
|
||||
if(isAutoconnectBroken) {
|
||||
logger.error('Server autoconnect disabled on Forge 1.15.2 for builds earlier than 31.2.15 due to OpenGL Stack Overflow issue.')
|
||||
logger.error('Please upgrade your Forge version to at least 31.2.15!')
|
||||
} else {
|
||||
this._processAutoConnectArg(args)
|
||||
}
|
||||
|
||||
|
||||
// Forge Specific Arguments
|
||||
args = args.concat(this.forgeData.arguments.game)
|
||||
|
||||
// Filter null values
|
||||
args = args.filter(arg => {
|
||||
@ -507,89 +340,7 @@ class ProcessBuilder {
|
||||
*
|
||||
* @returns {Array.<string>} An array containing the arguments required by forge.
|
||||
*/
|
||||
_resolveForgeArgs(){
|
||||
const mcArgs = this.forgeData.minecraftArguments.split(' ')
|
||||
const argDiscovery = /\${*(.*)}/
|
||||
|
||||
// Replace the declared variables with their proper values.
|
||||
for(let i=0; i<mcArgs.length; ++i){
|
||||
if(argDiscovery.test(mcArgs[i])){
|
||||
const identifier = mcArgs[i].match(argDiscovery)[1]
|
||||
let val = null
|
||||
switch(identifier){
|
||||
case 'auth_player_name':
|
||||
val = this.authUser.displayName.trim()
|
||||
break
|
||||
case 'version_name':
|
||||
//val = versionData.id
|
||||
val = this.server.getID()
|
||||
break
|
||||
case 'game_directory':
|
||||
val = this.gameDir
|
||||
break
|
||||
case 'assets_root':
|
||||
val = path.join(this.commonDir, 'assets')
|
||||
break
|
||||
case 'assets_index_name':
|
||||
val = this.versionData.assets
|
||||
break
|
||||
case 'auth_uuid':
|
||||
val = this.authUser.uuid.trim()
|
||||
break
|
||||
case 'auth_access_token':
|
||||
val = this.authUser.accessToken
|
||||
break
|
||||
case 'user_type':
|
||||
val = 'mojang'
|
||||
break
|
||||
case 'user_properties': // 1.8.9 and below.
|
||||
val = '{}'
|
||||
break
|
||||
case 'version_type':
|
||||
val = this.versionData.type
|
||||
break
|
||||
}
|
||||
if(val != null){
|
||||
mcArgs[i] = val
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Autoconnect to the selected server.
|
||||
this._processAutoConnectArg(mcArgs)
|
||||
|
||||
// Prepare game resolution
|
||||
if(ConfigManager.getFullscreen()){
|
||||
mcArgs.push('--fullscreen')
|
||||
mcArgs.push(true)
|
||||
} else {
|
||||
mcArgs.push('--width')
|
||||
mcArgs.push(ConfigManager.getGameWidth())
|
||||
mcArgs.push('--height')
|
||||
mcArgs.push(ConfigManager.getGameHeight())
|
||||
}
|
||||
|
||||
// Mod List File Argument
|
||||
mcArgs.push('--modListFile')
|
||||
if(this._lteMinorVersion(9)) {
|
||||
mcArgs.push(path.basename(this.fmlDir))
|
||||
} else {
|
||||
mcArgs.push('absolute:' + this.fmlDir)
|
||||
}
|
||||
|
||||
|
||||
// LiteLoader
|
||||
if(this.usingLiteLoader){
|
||||
mcArgs.push('--modRepo')
|
||||
mcArgs.push(this.llDir)
|
||||
|
||||
// Set first arg to liteloader tweak class
|
||||
mcArgs.unshift('com.mumfrey.liteloader.launch.LiteLoaderTweaker')
|
||||
mcArgs.unshift('--tweakClass')
|
||||
}
|
||||
|
||||
return mcArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the classpath entries all point to jar files.
|
||||
@ -600,9 +351,9 @@ class ProcessBuilder {
|
||||
|
||||
const ext = '.jar'
|
||||
const extLen = ext.length
|
||||
for(let i=0; i<list.length; i++) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const extIndex = list[i].indexOf(ext)
|
||||
if(extIndex > -1 && extIndex !== list[i].length - extLen) {
|
||||
if (extIndex > -1 && extIndex !== list[i].length - extLen) {
|
||||
list[i] = list[i].substring(0, extIndex + extLen)
|
||||
}
|
||||
}
|
||||
@ -618,33 +369,42 @@ class ProcessBuilder {
|
||||
* @param {string} tempNativePath The path to store the native libraries.
|
||||
* @returns {Array.<string>} An array containing the paths of each library required by this process.
|
||||
*/
|
||||
classpathArg(mods, tempNativePath){
|
||||
classpathArg(tempNativePath) {
|
||||
let cpArgs = []
|
||||
|
||||
// Add the version.jar to the classpath.
|
||||
const version = this.versionData.id
|
||||
cpArgs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
|
||||
|
||||
if(this.usingLiteLoader){
|
||||
cpArgs.push(this.llPath)
|
||||
}
|
||||
// cpArgs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
|
||||
|
||||
// Resolve the Mojang declared libraries.
|
||||
const mojangLibs = this._resolveMojangLibraries(tempNativePath)
|
||||
const mojangLibs = this._resolveMojangLibraries(tempNativePath, version)
|
||||
const optifineLibs = this._resolveOptifineLibs(this.server)
|
||||
|
||||
|
||||
// Resolve the server declared libraries.
|
||||
const servLibs = this._resolveServerLibraries(mods)
|
||||
|
||||
|
||||
// Merge libraries, server libs with the same
|
||||
// maven identifier will override the mojang ones.
|
||||
// Ex. 1.7.10 forge overrides mojang's guava with newer version.
|
||||
const finalLibs = {...mojangLibs, ...servLibs}
|
||||
cpArgs = cpArgs.concat(Object.values(finalLibs))
|
||||
|
||||
cpArgs = cpArgs.concat(Object.values(optifineLibs), Object.values(mojangLibs))
|
||||
cpArgs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
|
||||
|
||||
|
||||
this._processClassPathList(cpArgs)
|
||||
|
||||
return cpArgs
|
||||
}
|
||||
_resolveOptifineLibs(server) {
|
||||
let paths = []
|
||||
|
||||
// console.log(this.commonDir, 'libraries', 'optifine', 'Optifine', server.getOptifineVersion(), 'Optifine-' + server.getOptifineVersion() + '.jar')
|
||||
// console.log(this.commonDir, 'libraries', 'optifine', 'launchwrapper-of', server.getLaunchWrapperVersion(), 'laucnhwrapper-of-' + server.getLaunchWrapperVersion() + '.jar')
|
||||
paths.push(path.join(this.commonDir, 'libraries/optifine/launchwrapper-of/' + server.getLaunchWrapperVersion() + '/launchwrapper-of-' + server.getLaunchWrapperVersion() + '.jar'))
|
||||
paths.push(path.join(this.commonDir, 'libraries/optifine/Optifine/' + server.getOptifineVersion() + '/Optifine-' + server.getOptifineVersion() + '.jar'))
|
||||
return paths
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve the libraries defined by Mojang's version data. This method will also extract
|
||||
@ -655,15 +415,15 @@ class ProcessBuilder {
|
||||
* @param {string} tempNativePath The path to store the native libraries.
|
||||
* @returns {{[id: string]: string}} An object containing the paths of each library mojang declares.
|
||||
*/
|
||||
_resolveMojangLibraries(tempNativePath){
|
||||
_resolveMojangLibraries(tempNativePath, version) {
|
||||
const libs = {}
|
||||
|
||||
// path.join(this.commonDir, 'versions', version, version + '.jar')libs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
|
||||
const libArr = this.versionData.libraries
|
||||
fs.ensureDirSync(tempNativePath)
|
||||
for(let i=0; i<libArr.length; i++){
|
||||
for (let i = 0; i < libArr.length; i++) {
|
||||
const lib = libArr[i]
|
||||
if(Library.validateRules(lib.rules, lib.natives)){
|
||||
if(lib.natives == null){
|
||||
if (Library.validateRules(lib.rules, lib.natives)) {
|
||||
if (lib.natives == null) {
|
||||
const dlInfo = lib.downloads
|
||||
const artifact = dlInfo.artifact
|
||||
const to = path.join(this.libPath, artifact.path)
|
||||
@ -673,35 +433,35 @@ class ProcessBuilder {
|
||||
// Extract the native library.
|
||||
const exclusionArr = lib.extract != null ? lib.extract.exclude : ['META-INF/']
|
||||
const artifact = lib.downloads.classifiers[lib.natives[Library.mojangFriendlyOS()].replace('${arch}', process.arch.replace('x', ''))]
|
||||
|
||||
|
||||
// Location of native zip.
|
||||
const to = path.join(this.libPath, artifact.path)
|
||||
|
||||
|
||||
let zip = new AdmZip(to)
|
||||
let zipEntries = zip.getEntries()
|
||||
|
||||
|
||||
// Unzip the native zip.
|
||||
for(let i=0; i<zipEntries.length; i++){
|
||||
for (let i = 0; i < zipEntries.length; i++) {
|
||||
const fileName = zipEntries[i].entryName
|
||||
|
||||
|
||||
let shouldExclude = false
|
||||
|
||||
// Exclude noted files.
|
||||
exclusionArr.forEach(function(exclusion){
|
||||
if(fileName.indexOf(exclusion) > -1){
|
||||
exclusionArr.forEach(function (exclusion) {
|
||||
if (fileName.indexOf(exclusion) > -1) {
|
||||
shouldExclude = true
|
||||
}
|
||||
})
|
||||
|
||||
// Extract the file.
|
||||
if(!shouldExclude){
|
||||
if (!shouldExclude) {
|
||||
fs.writeFile(path.join(tempNativePath, fileName), zipEntries[i].getData(), (err) => {
|
||||
if(err){
|
||||
if (err) {
|
||||
logger.error('Error while extracting native library:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -718,36 +478,6 @@ class ProcessBuilder {
|
||||
* @param {Array.<Object>} mods An array of enabled mods which will be launched with this process.
|
||||
* @returns {{[id: string]: string}} An object containing the paths of each library this server requires.
|
||||
*/
|
||||
_resolveServerLibraries(mods){
|
||||
const mdls = this.server.getModules()
|
||||
let libs = {}
|
||||
|
||||
// Locate Forge/Libraries
|
||||
for(let mdl of mdls){
|
||||
const type = mdl.getType()
|
||||
if(type === DistroManager.Types.ForgeHosted || type === DistroManager.Types.Library){
|
||||
libs[mdl.getVersionlessID()] = mdl.getArtifact().getPath()
|
||||
if(mdl.hasSubModules()){
|
||||
const res = this._resolveModuleLibraries(mdl)
|
||||
if(res.length > 0){
|
||||
libs = {...libs, ...res}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check for any libraries in our mod list.
|
||||
for(let i=0; i<mods.length; i++){
|
||||
if(mods.sub_modules != null){
|
||||
const res = this._resolveModuleLibraries(mods[i])
|
||||
if(res.length > 0){
|
||||
libs = {...libs, ...res}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return libs
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively resolve the path of each library required by this module.
|
||||
@ -755,20 +485,20 @@ class ProcessBuilder {
|
||||
* @param {Object} mdl A module object from the server distro index.
|
||||
* @returns {Array.<string>} An array containing the paths of each library this module requires.
|
||||
*/
|
||||
_resolveModuleLibraries(mdl){
|
||||
if(!mdl.hasSubModules()){
|
||||
_resolveModuleLibraries(mdl) {
|
||||
if (!mdl.hasSubModules()) {
|
||||
return []
|
||||
}
|
||||
let libs = []
|
||||
for(let sm of mdl.getSubModules()){
|
||||
if(sm.getType() === DistroManager.Types.Library){
|
||||
for (let sm of mdl.getSubModules()) {
|
||||
if (sm.getType() === DistroManager.Types.Library) {
|
||||
libs.push(sm.getArtifact().getPath())
|
||||
}
|
||||
// If this module has submodules, we need to resolve the libraries for those.
|
||||
// To avoid unnecessary recursive calls, base case is checked here.
|
||||
if(mdl.hasSubModules()){
|
||||
if (mdl.hasSubModules()) {
|
||||
const res = this._resolveModuleLibraries(sm)
|
||||
if(res.length > 0){
|
||||
if (res.length > 0) {
|
||||
libs = libs.concat(res)
|
||||
}
|
||||
}
|
||||
|
@ -631,22 +631,15 @@ function dlAsync(login = true){
|
||||
let allGood = true
|
||||
|
||||
// If these properties are not defined it's likely an error.
|
||||
if(m.result.forgeData == null || m.result.versionData == null){
|
||||
loggerLaunchSuite.error('Error during validation:', m.result)
|
||||
|
||||
|
||||
loggerLaunchSuite.error('Error during launch', m.result.error)
|
||||
showLaunchFailure('Error During Launch', 'Please check the console (CTRL + Shift + i) for more details.')
|
||||
|
||||
allGood = false
|
||||
}
|
||||
|
||||
forgeData = m.result.forgeData
|
||||
// forgeData = m.result.forgeData
|
||||
versionData = m.result.versionData
|
||||
|
||||
if(login && allGood) {
|
||||
const authUser = ConfigManager.getSelectedAccount()
|
||||
loggerLaunchSuite.log(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
|
||||
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
|
||||
let pb = new ProcessBuilder(serv, versionData, authUser, remote.app.getVersion())
|
||||
setLaunchDetails('Launching game..')
|
||||
|
||||
const onLoadComplete = () => {
|
||||
|
10
build.js
10
build.js
@ -18,8 +18,8 @@ function getCurrentPlatform(){
|
||||
builder.build({
|
||||
targets: (process.argv[2] != null && Platform[process.argv[2]] != null ? Platform[process.argv[2]] : getCurrentPlatform()).createTarget(),
|
||||
config: {
|
||||
appId: 'helioslauncher',
|
||||
productName: 'Helios Launcher',
|
||||
appId: 'nexuslauncher',
|
||||
productName: 'NexusLauncher',
|
||||
artifactName: '${productName}-setup-${version}.${ext}',
|
||||
copyright: 'Copyright © 2018-2020 Daniel Scalzi',
|
||||
directories: {
|
||||
@ -46,10 +46,10 @@ builder.build({
|
||||
},
|
||||
linux: {
|
||||
target: 'AppImage',
|
||||
maintainer: 'Daniel Scalzi',
|
||||
maintainer: 'Daniel Scalzi, Dr_Dee',
|
||||
vendor: 'Daniel Scalzi',
|
||||
synopsis: 'Modded Minecraft Launcher',
|
||||
description: 'Custom launcher which allows users to join modded servers. All mods, configurations, and updates are handled automatically.',
|
||||
synopsis: 'Minecraft Launcher für MC-Nexus.de',
|
||||
description: '---',
|
||||
category: 'Game'
|
||||
},
|
||||
compression: 'maximum',
|
||||
|
Loading…
Reference in New Issue
Block a user