mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 19:52:14 -08:00
Compare commits
3 Commits
bf87d83203
...
e60096b328
Author | SHA1 | Date | |
---|---|---|---|
|
e60096b328 | ||
|
6d79076da8 | ||
|
2d9a860fc1 |
@ -12,23 +12,14 @@ const ConfigManager = require('./configmanager')
|
|||||||
|
|
||||||
const logger = LoggerUtil.getLogger('ProcessBuilder')
|
const logger = LoggerUtil.getLogger('ProcessBuilder')
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only forge and fabric are top level mod loaders.
|
|
||||||
*
|
|
||||||
* Forge 1.13+ launch logic is similar to fabrics, for now using usingFabricLoader flag to
|
|
||||||
* change minor details when needed.
|
|
||||||
*
|
|
||||||
* Rewrite of this module may be needed in the future.
|
|
||||||
*/
|
|
||||||
class ProcessBuilder {
|
class ProcessBuilder {
|
||||||
|
|
||||||
constructor(distroServer, vanillaManifest, modManifest, authUser, launcherVersion){
|
constructor(distroServer, versionData, forgeData, authUser, launcherVersion){
|
||||||
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.rawServer.id)
|
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.rawServer.id)
|
||||||
this.commonDir = ConfigManager.getCommonDirectory()
|
this.commonDir = ConfigManager.getCommonDirectory()
|
||||||
this.server = distroServer
|
this.server = distroServer
|
||||||
this.vanillaManifest = vanillaManifest
|
this.versionData = versionData
|
||||||
this.modManifest = modManifest
|
this.forgeData = forgeData
|
||||||
this.authUser = authUser
|
this.authUser = authUser
|
||||||
this.launcherVersion = launcherVersion
|
this.launcherVersion = launcherVersion
|
||||||
this.forgeModListFile = path.join(this.gameDir, 'forgeMods.list') // 1.13+
|
this.forgeModListFile = path.join(this.gameDir, 'forgeMods.list') // 1.13+
|
||||||
@ -207,7 +198,7 @@ class ProcessBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_lteMinorVersion(version) {
|
_lteMinorVersion(version) {
|
||||||
return Number(this.modManifest.id.split('-')[0].split('.')[1]) <= Number(version)
|
return Number(this.forgeData.id.split('-')[0].split('.')[1]) <= Number(version)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,7 +210,7 @@ class ProcessBuilder {
|
|||||||
if(this._lteMinorVersion(9)) {
|
if(this._lteMinorVersion(9)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
const ver = this.modManifest.id.split('-')[2]
|
const ver = this.forgeData.id.split('-')[2]
|
||||||
const pts = ver.split('.')
|
const pts = ver.split('.')
|
||||||
const min = [14, 23, 3, 2655]
|
const min = [14, 23, 3, 2655]
|
||||||
for(let i=0; i<pts.length; i++){
|
for(let i=0; i<pts.length; i++){
|
||||||
@ -377,7 +368,7 @@ class ProcessBuilder {
|
|||||||
args.push('-Djava.library.path=' + tempNativePath)
|
args.push('-Djava.library.path=' + tempNativePath)
|
||||||
|
|
||||||
// Main Java Class
|
// Main Java Class
|
||||||
args.push(this.modManifest.mainClass)
|
args.push(this.forgeData.mainClass)
|
||||||
|
|
||||||
// Forge Arguments
|
// Forge Arguments
|
||||||
args = args.concat(this._resolveForgeArgs())
|
args = args.concat(this._resolveForgeArgs())
|
||||||
@ -400,17 +391,17 @@ class ProcessBuilder {
|
|||||||
const argDiscovery = /\${*(.*)}/
|
const argDiscovery = /\${*(.*)}/
|
||||||
|
|
||||||
// JVM Arguments First
|
// JVM Arguments First
|
||||||
let args = this.vanillaManifest.arguments.jvm
|
let args = this.versionData.arguments.jvm
|
||||||
|
|
||||||
// Debug securejarhandler
|
// Debug securejarhandler
|
||||||
// args.push('-Dbsl.debug=true')
|
// args.push('-Dbsl.debug=true')
|
||||||
|
|
||||||
if(this.modManifest.arguments.jvm != null) {
|
if(this.forgeData.arguments.jvm != null) {
|
||||||
for(const argStr of this.modManifest.arguments.jvm) {
|
for(const argStr of this.forgeData.arguments.jvm) {
|
||||||
args.push(argStr
|
args.push(argStr
|
||||||
.replaceAll('${library_directory}', this.libPath)
|
.replaceAll('${library_directory}', this.libPath)
|
||||||
.replaceAll('${classpath_separator}', ProcessBuilder.getClasspathSeparator())
|
.replaceAll('${classpath_separator}', ProcessBuilder.getClasspathSeparator())
|
||||||
.replaceAll('${version_name}', this.modManifest.id)
|
.replaceAll('${version_name}', this.forgeData.id)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,10 +418,10 @@ class ProcessBuilder {
|
|||||||
args = args.concat(ConfigManager.getJVMOptions(this.server.rawServer.id))
|
args = args.concat(ConfigManager.getJVMOptions(this.server.rawServer.id))
|
||||||
|
|
||||||
// Main Java Class
|
// Main Java Class
|
||||||
args.push(this.modManifest.mainClass)
|
args.push(this.forgeData.mainClass)
|
||||||
|
|
||||||
// Vanilla Arguments
|
// Vanilla Arguments
|
||||||
args = args.concat(this.vanillaManifest.arguments.game)
|
args = args.concat(this.versionData.arguments.game)
|
||||||
|
|
||||||
for(let i=0; i<args.length; i++){
|
for(let i=0; i<args.length; i++){
|
||||||
if(typeof args[i] === 'object' && args[i].rules != null){
|
if(typeof args[i] === 'object' && args[i].rules != null){
|
||||||
@ -487,7 +478,7 @@ class ProcessBuilder {
|
|||||||
val = this.authUser.displayName.trim()
|
val = this.authUser.displayName.trim()
|
||||||
break
|
break
|
||||||
case 'version_name':
|
case 'version_name':
|
||||||
//val = vanillaManifest.id
|
//val = versionData.id
|
||||||
val = this.server.rawServer.id
|
val = this.server.rawServer.id
|
||||||
break
|
break
|
||||||
case 'game_directory':
|
case 'game_directory':
|
||||||
@ -497,7 +488,7 @@ class ProcessBuilder {
|
|||||||
val = path.join(this.commonDir, 'assets')
|
val = path.join(this.commonDir, 'assets')
|
||||||
break
|
break
|
||||||
case 'assets_index_name':
|
case 'assets_index_name':
|
||||||
val = this.vanillaManifest.assets
|
val = this.versionData.assets
|
||||||
break
|
break
|
||||||
case 'auth_uuid':
|
case 'auth_uuid':
|
||||||
val = this.authUser.uuid.trim()
|
val = this.authUser.uuid.trim()
|
||||||
@ -509,7 +500,7 @@ class ProcessBuilder {
|
|||||||
val = this.authUser.type === 'microsoft' ? 'msa' : 'mojang'
|
val = this.authUser.type === 'microsoft' ? 'msa' : 'mojang'
|
||||||
break
|
break
|
||||||
case 'version_type':
|
case 'version_type':
|
||||||
val = this.vanillaManifest.type
|
val = this.versionData.type
|
||||||
break
|
break
|
||||||
case 'resolution_width':
|
case 'resolution_width':
|
||||||
val = ConfigManager.getGameWidth()
|
val = ConfigManager.getGameWidth()
|
||||||
@ -538,11 +529,25 @@ class ProcessBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Autoconnect
|
// Autoconnect
|
||||||
|
let isAutoconnectBroken
|
||||||
|
try {
|
||||||
|
isAutoconnectBroken = ProcessBuilder.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)
|
this._processAutoConnectArg(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Forge Specific Arguments
|
// Forge Specific Arguments
|
||||||
args = args.concat(this.modManifest.arguments.game)
|
args = args.concat(this.forgeData.arguments.game)
|
||||||
|
|
||||||
// Filter null values
|
// Filter null values
|
||||||
args = args.filter(arg => {
|
args = args.filter(arg => {
|
||||||
@ -558,7 +563,7 @@ class ProcessBuilder {
|
|||||||
* @returns {Array.<string>} An array containing the arguments required by forge.
|
* @returns {Array.<string>} An array containing the arguments required by forge.
|
||||||
*/
|
*/
|
||||||
_resolveForgeArgs(){
|
_resolveForgeArgs(){
|
||||||
const mcArgs = this.modManifest.minecraftArguments.split(' ')
|
const mcArgs = this.forgeData.minecraftArguments.split(' ')
|
||||||
const argDiscovery = /\${*(.*)}/
|
const argDiscovery = /\${*(.*)}/
|
||||||
|
|
||||||
// Replace the declared variables with their proper values.
|
// Replace the declared variables with their proper values.
|
||||||
@ -571,7 +576,7 @@ class ProcessBuilder {
|
|||||||
val = this.authUser.displayName.trim()
|
val = this.authUser.displayName.trim()
|
||||||
break
|
break
|
||||||
case 'version_name':
|
case 'version_name':
|
||||||
//val = vanillaManifest.id
|
//val = versionData.id
|
||||||
val = this.server.rawServer.id
|
val = this.server.rawServer.id
|
||||||
break
|
break
|
||||||
case 'game_directory':
|
case 'game_directory':
|
||||||
@ -581,7 +586,7 @@ class ProcessBuilder {
|
|||||||
val = path.join(this.commonDir, 'assets')
|
val = path.join(this.commonDir, 'assets')
|
||||||
break
|
break
|
||||||
case 'assets_index_name':
|
case 'assets_index_name':
|
||||||
val = this.vanillaManifest.assets
|
val = this.versionData.assets
|
||||||
break
|
break
|
||||||
case 'auth_uuid':
|
case 'auth_uuid':
|
||||||
val = this.authUser.uuid.trim()
|
val = this.authUser.uuid.trim()
|
||||||
@ -596,7 +601,7 @@ class ProcessBuilder {
|
|||||||
val = '{}'
|
val = '{}'
|
||||||
break
|
break
|
||||||
case 'version_type':
|
case 'version_type':
|
||||||
val = this.vanillaManifest.type
|
val = this.versionData.type
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if(val != null){
|
if(val != null){
|
||||||
@ -674,7 +679,7 @@ class ProcessBuilder {
|
|||||||
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion) || this.usingFabricLoader) {
|
if(!mcVersionAtLeast('1.17', this.server.rawServer.minecraftVersion) || this.usingFabricLoader) {
|
||||||
// Add the version.jar to the classpath.
|
// Add the version.jar to the classpath.
|
||||||
// Must not be added to the classpath for Forge 1.17+.
|
// Must not be added to the classpath for Forge 1.17+.
|
||||||
const version = this.vanillaManifest.id
|
const version = this.versionData.id
|
||||||
cpArgs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
|
cpArgs.push(path.join(this.commonDir, 'versions', version, version + '.jar'))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -713,7 +718,7 @@ class ProcessBuilder {
|
|||||||
const nativesRegex = /.+:natives-([^-]+)(?:-(.+))?/
|
const nativesRegex = /.+:natives-([^-]+)(?:-(.+))?/
|
||||||
const libs = {}
|
const libs = {}
|
||||||
|
|
||||||
const libArr = this.vanillaManifest.libraries
|
const libArr = this.versionData.libraries
|
||||||
fs.ensureDirSync(tempNativePath)
|
fs.ensureDirSync(tempNativePath)
|
||||||
for(let i=0; i<libArr.length; i++){
|
for(let i=0; i<libArr.length; i++){
|
||||||
const lib = libArr[i]
|
const lib = libArr[i]
|
||||||
@ -889,6 +894,24 @@ class ProcessBuilder {
|
|||||||
return libs
|
return libs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isAutoconnectBroken(forgeVersion) {
|
||||||
|
|
||||||
|
const minWorking = [31, 2, 15]
|
||||||
|
const verSplit = forgeVersion.split('.').map(v => Number(v))
|
||||||
|
|
||||||
|
if(verSplit[0] === 31) {
|
||||||
|
for(let i=0; i<minWorking.length; i++) {
|
||||||
|
if(verSplit[i] > minWorking[i]) {
|
||||||
|
return false
|
||||||
|
} else if(verSplit[i] < minWorking[i]) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ProcessBuilder
|
module.exports = ProcessBuilder
|
Loading…
Reference in New Issue
Block a user