Mise a jour
This commit is contained in:
parent
d8201e3624
commit
244c77832b
12
app/app.ejs
12
app/app.ejs
@ -47,6 +47,18 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="loading-view" style="display: none;">
|
||||
<div class="loading-container">
|
||||
<div class="paladium-loader"></div>
|
||||
|
||||
<div class="loading-text">
|
||||
<p id="loading-splash-text"></p>
|
||||
<p class="loading-sudmitted-text">Proposé par FullGreen.Sky</p>
|
||||
<p id="loading-statut-text">Chargement en cours</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
// Load language
|
||||
for (let key of Object.keys(Lang.query('html'))) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
let target = require('./assetguard')[process.argv[2]]
|
||||
if(target == null){
|
||||
process.send({context: 'error', data: null, error: 'Invalid class name'})
|
||||
console.error('Invalid class name passed to argv[2], cannot continue.')
|
||||
if (target == null) {
|
||||
process.send({ context: 'error', data: null, error: 'Nom de classe non valide' })
|
||||
console.error('Nom de classe non valide transmis à argv[2], impossible de continuer.')
|
||||
process.exit(1)
|
||||
}
|
||||
let tracker = new target(...(process.argv.splice(3)))
|
||||
@ -13,51 +13,52 @@ console.log('AssetExec Started')
|
||||
process.on('unhandledRejection', r => console.log(r))
|
||||
|
||||
let percent = 0
|
||||
function assignListeners(){
|
||||
|
||||
function assignListeners() {
|
||||
tracker.on('validate', (data) => {
|
||||
process.send({context: 'validate', data})
|
||||
process.send({ context: 'validate', data })
|
||||
})
|
||||
tracker.on('progress', (data, acc, total) => {
|
||||
const currPercent = parseInt((acc/total) * 100)
|
||||
const currPercent = parseInt((acc / total) * 100)
|
||||
if (currPercent !== percent) {
|
||||
percent = currPercent
|
||||
process.send({context: 'progress', data, value: acc, total, percent})
|
||||
process.send({ context: 'progress', data, value: acc, total, percent })
|
||||
}
|
||||
})
|
||||
tracker.on('complete', (data, ...args) => {
|
||||
process.send({context: 'complete', data, args})
|
||||
process.send({ context: 'complete', data, args })
|
||||
})
|
||||
tracker.on('error', (data, error) => {
|
||||
process.send({context: 'error', data, error})
|
||||
process.send({ context: 'error', data, error })
|
||||
})
|
||||
}
|
||||
|
||||
assignListeners()
|
||||
|
||||
process.on('message', (msg) => {
|
||||
if(msg.task === 'execute'){
|
||||
if (msg.task === 'execute') {
|
||||
const func = msg.function
|
||||
let nS = tracker[func] // Nonstatic context
|
||||
let iS = target[func] // Static context
|
||||
if(typeof nS === 'function' || typeof iS === 'function'){
|
||||
if (typeof nS === 'function' || typeof iS === 'function') {
|
||||
const f = typeof nS === 'function' ? nS : iS
|
||||
const res = f.apply(f === nS ? tracker : null, msg.argsArr)
|
||||
if(res instanceof Promise){
|
||||
if (res instanceof Promise) {
|
||||
res.then((v) => {
|
||||
process.send({result: v, context: func})
|
||||
process.send({ result: v, context: func })
|
||||
}).catch((err) => {
|
||||
process.send({result: err.message || err, context: func})
|
||||
process.send({ result: err.message || err, context: func })
|
||||
})
|
||||
} else {
|
||||
process.send({result: res, context: func})
|
||||
process.send({ result: res, context: func })
|
||||
}
|
||||
} else {
|
||||
process.send({context: 'error', data: null, error: `Function ${func} not found on ${process.argv[2]}`})
|
||||
process.send({ context: 'error', data: null, error: `Function ${func} not found on ${process.argv[2]}` })
|
||||
}
|
||||
} else if(msg.task === 'changeContext'){
|
||||
} else if (msg.task === 'changeContext') {
|
||||
target = require('./assetguard')[msg.class]
|
||||
if(target == null){
|
||||
process.send({context: 'error', data: null, error: `Invalid class ${msg.class}`})
|
||||
if (target == null) {
|
||||
process.send({ context: 'error', data: null, error: `Classe invalide ${msg.class}` })
|
||||
} else {
|
||||
tracker = new target(...(msg.args))
|
||||
assignListeners()
|
||||
@ -66,6 +67,6 @@ process.on('message', (msg) => {
|
||||
})
|
||||
|
||||
process.on('disconnect', () => {
|
||||
console.log('AssetExec Disconnected')
|
||||
console.log('AssetExec déconnecté')
|
||||
process.exit(0)
|
||||
})
|
File diff suppressed because it is too large
Load Diff
@ -26,12 +26,12 @@ const loggerSuccess = LoggerUtil('%c[AuthManager]', 'color: #209b07; font-weight
|
||||
* @param {string} password The account password.
|
||||
* @returns {Promise.<Object>} Promise which resolves the resolved authenticated account object.
|
||||
*/
|
||||
exports.addAccount = async function(username, password){
|
||||
exports.addAccount = async function(username, password) {
|
||||
try {
|
||||
const session = await Mojang.authenticate(username, password, ConfigManager.getClientToken())
|
||||
if(session.selectedProfile != null){
|
||||
if (session.selectedProfile != null) {
|
||||
const ret = ConfigManager.addAuthAccount(session.selectedProfile.id, session.accessToken, username, session.selectedProfile.name)
|
||||
if(ConfigManager.getClientToken() == null){
|
||||
if (ConfigManager.getClientToken() == null) {
|
||||
ConfigManager.setClientToken(session.clientToken)
|
||||
}
|
||||
ConfigManager.save()
|
||||
@ -40,7 +40,7 @@ exports.addAccount = async function(username, password){
|
||||
throw new Error('NotPaidAccount')
|
||||
}
|
||||
|
||||
} catch (err){
|
||||
} catch (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
}
|
||||
@ -52,14 +52,14 @@ exports.addAccount = async function(username, password){
|
||||
* @param {string} uuid The UUID of the account to be removed.
|
||||
* @returns {Promise.<void>} Promise which resolves to void when the action is complete.
|
||||
*/
|
||||
exports.removeAccount = async function(uuid){
|
||||
exports.removeAccount = async function(uuid) {
|
||||
try {
|
||||
const authAcc = ConfigManager.getAuthAccount(uuid)
|
||||
await Mojang.invalidate(authAcc.accessToken, ConfigManager.getClientToken())
|
||||
ConfigManager.removeAuthAccount(uuid)
|
||||
ConfigManager.save()
|
||||
return Promise.resolve()
|
||||
} catch (err){
|
||||
} catch (err) {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
}
|
||||
@ -74,26 +74,26 @@ exports.removeAccount = async function(uuid){
|
||||
* @returns {Promise.<boolean>} Promise which resolves to true if the access token is valid,
|
||||
* otherwise false.
|
||||
*/
|
||||
exports.validateSelected = async function(){
|
||||
exports.validateSelected = async function() {
|
||||
const current = ConfigManager.getSelectedAccount()
|
||||
const isValid = await Mojang.validate(current.accessToken, ConfigManager.getClientToken())
|
||||
if(!isValid){
|
||||
if (!isValid) {
|
||||
try {
|
||||
const session = await Mojang.refresh(current.accessToken, ConfigManager.getClientToken())
|
||||
ConfigManager.updateAuthAccount(current.uuid, session.accessToken)
|
||||
ConfigManager.save()
|
||||
} catch(err) {
|
||||
logger.debug('Error while validating selected profile:', err)
|
||||
if(err && err.error === 'ForbiddenOperationException'){
|
||||
} catch (err) {
|
||||
logger.debug('Erreur lors de la validation du profil sélectionné:', err)
|
||||
if (err && err.error === 'ForbiddenOperationException') {
|
||||
// What do we do?
|
||||
}
|
||||
logger.log('Account access token is invalid.')
|
||||
logger.log('Le jeton d\'accès au compte n\'est pas valide.')
|
||||
return false
|
||||
}
|
||||
loggerSuccess.log('Account access token validated.')
|
||||
loggerSuccess.log('Jeton d\'accès au compte validé.')
|
||||
return true
|
||||
} else {
|
||||
loggerSuccess.log('Account access token validated.')
|
||||
loggerSuccess.log('Jeton d\'accès au compte validé.')
|
||||
return true
|
||||
}
|
||||
}
|
@ -144,8 +144,8 @@ exports.load = function() {
|
||||
doValidate = true
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
logger.log('Configuration file contains malformed JSON or is corrupt.')
|
||||
logger.log('Generating a new configuration file.')
|
||||
logger.log('Le fichier de configuration contient un JSON mal formé ou corrompu.')
|
||||
logger.log('Génération d\'un nouveau fichier de configuration.')
|
||||
fs.ensureDirSync(path.join(configPath, '..'))
|
||||
config = DEFAULT_CONFIG
|
||||
exports.save()
|
||||
@ -155,7 +155,7 @@ exports.load = function() {
|
||||
exports.save()
|
||||
}
|
||||
}
|
||||
logger.log('Successfully Loaded')
|
||||
logger.log('Chargé avec succès')
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,16 +35,16 @@ exports.validateDir = function(dir) {
|
||||
*/
|
||||
exports.scanForDropinMods = function(modsDir, version) {
|
||||
const modsDiscovered = []
|
||||
if(fs.existsSync(modsDir)){
|
||||
if (fs.existsSync(modsDir)) {
|
||||
let modCandidates = fs.readdirSync(modsDir)
|
||||
let verCandidates = []
|
||||
const versionDir = path.join(modsDir, version)
|
||||
if(fs.existsSync(versionDir)){
|
||||
if (fs.existsSync(versionDir)) {
|
||||
verCandidates = fs.readdirSync(versionDir)
|
||||
}
|
||||
for(let file of modCandidates){
|
||||
for (let file of modCandidates) {
|
||||
const match = MOD_REGEX.exec(file)
|
||||
if(match != null){
|
||||
if (match != null) {
|
||||
modsDiscovered.push({
|
||||
fullName: match[0],
|
||||
name: match[1],
|
||||
@ -53,9 +53,9 @@ exports.scanForDropinMods = function(modsDir, version) {
|
||||
})
|
||||
}
|
||||
}
|
||||
for(let file of verCandidates){
|
||||
for (let file of verCandidates) {
|
||||
const match = MOD_REGEX.exec(file)
|
||||
if(match != null){
|
||||
if (match != null) {
|
||||
modsDiscovered.push({
|
||||
fullName: path.join(version, match[0]),
|
||||
name: match[1],
|
||||
@ -78,8 +78,8 @@ exports.addDropinMods = function(files, modsdir) {
|
||||
|
||||
exports.validateDir(modsdir)
|
||||
|
||||
for(let f of files) {
|
||||
if(MOD_REGEX.exec(f.name) != null) {
|
||||
for (let f of files) {
|
||||
if (MOD_REGEX.exec(f.name) != null) {
|
||||
fs.moveSync(f.path, path.join(modsdir, f.name))
|
||||
}
|
||||
}
|
||||
@ -94,9 +94,9 @@ exports.addDropinMods = function(files, modsdir) {
|
||||
*
|
||||
* @returns {boolean} True if the mod was deleted, otherwise false.
|
||||
*/
|
||||
exports.deleteDropinMod = function(modsDir, fullName){
|
||||
exports.deleteDropinMod = function(modsDir, fullName) {
|
||||
const res = shell.moveItemToTrash(path.join(modsDir, fullName))
|
||||
if(!res){
|
||||
if (!res) {
|
||||
shell.beep()
|
||||
}
|
||||
return res
|
||||
@ -113,13 +113,13 @@ exports.deleteDropinMod = function(modsDir, fullName){
|
||||
* @returns {Promise.<void>} A promise which resolves when the mod has
|
||||
* been toggled. If an IO error occurs the promise will be rejected.
|
||||
*/
|
||||
exports.toggleDropinMod = function(modsDir, fullName, enable){
|
||||
exports.toggleDropinMod = function(modsDir, fullName, enable) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const oldPath = path.join(modsDir, fullName)
|
||||
const newPath = path.join(modsDir, enable ? fullName.substring(0, fullName.indexOf(DISABLED_EXT)) : fullName + DISABLED_EXT)
|
||||
|
||||
fs.rename(oldPath, newPath, (err) => {
|
||||
if(err){
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
resolve()
|
||||
@ -134,7 +134,7 @@ exports.toggleDropinMod = function(modsDir, fullName, enable){
|
||||
* @param {string} fullName The fullName of the discovered mod to toggle.
|
||||
* @returns {boolean} True if the mod is enabled, otherwise false.
|
||||
*/
|
||||
exports.isDropinModEnabled = function(fullName){
|
||||
exports.isDropinModEnabled = function(fullName) {
|
||||
return !fullName.endsWith(DISABLED_EXT)
|
||||
}
|
||||
|
||||
@ -146,17 +146,17 @@ exports.isDropinModEnabled = function(fullName){
|
||||
* @returns {{fullName: string, name: string}[]}
|
||||
* An array of objects storing metadata about each discovered shaderpack.
|
||||
*/
|
||||
exports.scanForShaderpacks = function(instanceDir){
|
||||
exports.scanForShaderpacks = function(instanceDir) {
|
||||
const shaderDir = path.join(instanceDir, SHADER_DIR)
|
||||
const packsDiscovered = [{
|
||||
fullName: 'OFF',
|
||||
name: 'Off (Default)'
|
||||
}]
|
||||
if(fs.existsSync(shaderDir)){
|
||||
if (fs.existsSync(shaderDir)) {
|
||||
let modCandidates = fs.readdirSync(shaderDir)
|
||||
for(let file of modCandidates){
|
||||
for (let file of modCandidates) {
|
||||
const match = SHADER_REGEX.exec(file)
|
||||
if(match != null){
|
||||
if (match != null) {
|
||||
packsDiscovered.push({
|
||||
fullName: match[0],
|
||||
name: match[1]
|
||||
@ -175,17 +175,17 @@ exports.scanForShaderpacks = function(instanceDir){
|
||||
*
|
||||
* @returns {string} The file name of the enabled shaderpack.
|
||||
*/
|
||||
exports.getEnabledShaderpack = function(instanceDir){
|
||||
exports.getEnabledShaderpack = function(instanceDir) {
|
||||
exports.validateDir(instanceDir)
|
||||
|
||||
const optionsShaders = path.join(instanceDir, SHADER_CONFIG)
|
||||
if(fs.existsSync(optionsShaders)){
|
||||
const buf = fs.readFileSync(optionsShaders, {encoding: 'utf-8'})
|
||||
if (fs.existsSync(optionsShaders)) {
|
||||
const buf = fs.readFileSync(optionsShaders, { encoding: 'utf-8' })
|
||||
const match = SHADER_OPTION.exec(buf)
|
||||
if(match != null){
|
||||
if (match != null) {
|
||||
return match[1]
|
||||
} else {
|
||||
console.warn('WARNING: Shaderpack regex failed.')
|
||||
console.warn('AVERTISSEMENT: Shaderpack regex a échoué.')
|
||||
}
|
||||
}
|
||||
return 'OFF'
|
||||
@ -197,18 +197,18 @@ exports.getEnabledShaderpack = function(instanceDir){
|
||||
* @param {string} instanceDir The path to the server instance directory.
|
||||
* @param {string} pack the file name of the shaderpack.
|
||||
*/
|
||||
exports.setEnabledShaderpack = function(instanceDir, pack){
|
||||
exports.setEnabledShaderpack = function(instanceDir, pack) {
|
||||
exports.validateDir(instanceDir)
|
||||
|
||||
const optionsShaders = path.join(instanceDir, SHADER_CONFIG)
|
||||
let buf
|
||||
if(fs.existsSync(optionsShaders)){
|
||||
buf = fs.readFileSync(optionsShaders, {encoding: 'utf-8'})
|
||||
if (fs.existsSync(optionsShaders)) {
|
||||
buf = fs.readFileSync(optionsShaders, { encoding: 'utf-8' })
|
||||
buf = buf.replace(SHADER_OPTION, `shaderPack=${pack}`)
|
||||
} else {
|
||||
buf = `shaderPack=${pack}`
|
||||
}
|
||||
fs.writeFileSync(optionsShaders, buf, {encoding: 'utf-8'})
|
||||
fs.writeFileSync(optionsShaders, buf, { encoding: 'utf-8' })
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,8 +223,8 @@ exports.addShaderpacks = function(files, instanceDir) {
|
||||
|
||||
exports.validateDir(p)
|
||||
|
||||
for(let f of files) {
|
||||
if(SHADER_REGEX.exec(f.name) != null) {
|
||||
for (let f of files) {
|
||||
if (SHADER_REGEX.exec(f.name) != null) {
|
||||
fs.moveSync(f.path, path.join(p, f.name))
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,7 @@ const minecraftAgent = {
|
||||
version: 1
|
||||
}
|
||||
const authpath = 'https://authserver.mojang.com'
|
||||
const statuses = [
|
||||
{
|
||||
const statuses = [{
|
||||
service: 'sessionserver.mojang.com',
|
||||
status: 'grey',
|
||||
name: 'Multiplayer Session Service',
|
||||
@ -64,8 +63,8 @@ const statuses = [
|
||||
* @param {string} status A valid status code.
|
||||
* @returns {string} The hex color of the status code.
|
||||
*/
|
||||
exports.statusToHex = function(status){
|
||||
switch(status.toLowerCase()){
|
||||
exports.statusToHex = function(status) {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'green':
|
||||
return '#a5c325'
|
||||
case 'yellow':
|
||||
@ -86,29 +85,28 @@ exports.statusToHex = function(status){
|
||||
*
|
||||
* @see http://wiki.vg/Mojang_API#API_Status
|
||||
*/
|
||||
exports.status = function(){
|
||||
exports.status = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.get('https://status.mojang.com/check',
|
||||
{
|
||||
request.get('https://status.mojang.com/check', {
|
||||
json: true,
|
||||
timeout: 2500
|
||||
},
|
||||
function(error, response, body){
|
||||
function(error, response, body) {
|
||||
|
||||
if(error || response.statusCode !== 200){
|
||||
logger.warn('Unable to retrieve Mojang status.')
|
||||
logger.debug('Error while retrieving Mojang statuses:', error)
|
||||
if (error || response.statusCode !== 200) {
|
||||
logger.warn('Impossible de récupérer le statut Mojang.')
|
||||
logger.debug('Erreur lors de la récupération des statuts Mojang:', error)
|
||||
//reject(error || response.statusCode)
|
||||
for(let i=0; i<statuses.length; i++){
|
||||
for (let i = 0; i < statuses.length; i++) {
|
||||
statuses[i].status = 'grey'
|
||||
}
|
||||
resolve(statuses)
|
||||
} else {
|
||||
for(let i=0; i<body.length; i++){
|
||||
for (let i = 0; i < body.length; i++) {
|
||||
const key = Object.keys(body[i])[0]
|
||||
inner:
|
||||
for(let j=0; j<statuses.length; j++){
|
||||
if(statuses[j].service === key) {
|
||||
for (let j = 0; j < statuses.length; j++) {
|
||||
if (statuses[j].service === key) {
|
||||
statuses[j].status = body[i][key]
|
||||
break inner
|
||||
}
|
||||
@ -131,7 +129,7 @@ exports.status = function(){
|
||||
*
|
||||
* @see http://wiki.vg/Authentication#Authenticate
|
||||
*/
|
||||
exports.authenticate = function(username, password, clientToken, requestUser = true, agent = minecraftAgent){
|
||||
exports.authenticate = function(username, password, clientToken, requestUser = true, agent = minecraftAgent) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const body = {
|
||||
@ -140,24 +138,23 @@ exports.authenticate = function(username, password, clientToken, requestUser = t
|
||||
password,
|
||||
requestUser
|
||||
}
|
||||
if(clientToken != null){
|
||||
if (clientToken != null) {
|
||||
body.clientToken = clientToken
|
||||
}
|
||||
|
||||
request.post(authpath + '/authenticate',
|
||||
{
|
||||
request.post(authpath + '/authenticate', {
|
||||
json: true,
|
||||
body
|
||||
},
|
||||
function(error, response, body){
|
||||
if(error){
|
||||
logger.error('Error during authentication.', error)
|
||||
function(error, response, body) {
|
||||
if (error) {
|
||||
logger.error('Erreur lors de l\'authentification.', error)
|
||||
reject(error)
|
||||
} else {
|
||||
if(response.statusCode === 200){
|
||||
if (response.statusCode === 200) {
|
||||
resolve(body)
|
||||
} else {
|
||||
reject(body || {code: 'ENOTFOUND'})
|
||||
reject(body || { code: 'ENOTFOUND' })
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -173,22 +170,21 @@ exports.authenticate = function(username, password, clientToken, requestUser = t
|
||||
*
|
||||
* @see http://wiki.vg/Authentication#Validate
|
||||
*/
|
||||
exports.validate = function(accessToken, clientToken){
|
||||
exports.validate = function(accessToken, clientToken) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post(authpath + '/validate',
|
||||
{
|
||||
request.post(authpath + '/validate', {
|
||||
json: true,
|
||||
body: {
|
||||
accessToken,
|
||||
clientToken
|
||||
}
|
||||
},
|
||||
function(error, response, body){
|
||||
if(error){
|
||||
logger.error('Error during validation.', error)
|
||||
function(error, response, body) {
|
||||
if (error) {
|
||||
logger.error('Erreur lors de l\'authentification.', error)
|
||||
reject(error)
|
||||
} else {
|
||||
if(response.statusCode === 403){
|
||||
if (response.statusCode === 403) {
|
||||
resolve(false)
|
||||
} else {
|
||||
// 204 if valid
|
||||
@ -208,22 +204,21 @@ exports.validate = function(accessToken, clientToken){
|
||||
*
|
||||
* @see http://wiki.vg/Authentication#Invalidate
|
||||
*/
|
||||
exports.invalidate = function(accessToken, clientToken){
|
||||
exports.invalidate = function(accessToken, clientToken) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post(authpath + '/invalidate',
|
||||
{
|
||||
request.post(authpath + '/invalidate', {
|
||||
json: true,
|
||||
body: {
|
||||
accessToken,
|
||||
clientToken
|
||||
}
|
||||
},
|
||||
function(error, response, body){
|
||||
if(error){
|
||||
logger.error('Error during invalidation.', error)
|
||||
function(error, response, body) {
|
||||
if (error) {
|
||||
logger.error('Erreur lors de l\'authentification', error)
|
||||
reject(error)
|
||||
} else {
|
||||
if(response.statusCode === 204){
|
||||
if (response.statusCode === 204) {
|
||||
resolve()
|
||||
} else {
|
||||
reject(body)
|
||||
@ -244,10 +239,9 @@ exports.invalidate = function(accessToken, clientToken){
|
||||
*
|
||||
* @see http://wiki.vg/Authentication#Refresh
|
||||
*/
|
||||
exports.refresh = function(accessToken, clientToken, requestUser = true){
|
||||
exports.refresh = function(accessToken, clientToken, requestUser = true) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post(authpath + '/refresh',
|
||||
{
|
||||
request.post(authpath + '/refresh', {
|
||||
json: true,
|
||||
body: {
|
||||
accessToken,
|
||||
@ -255,12 +249,12 @@ exports.refresh = function(accessToken, clientToken, requestUser = true){
|
||||
requestUser
|
||||
}
|
||||
},
|
||||
function(error, response, body){
|
||||
if(error){
|
||||
logger.error('Error during refresh.', error)
|
||||
function(error, response, body) {
|
||||
if (error) {
|
||||
logger.error('Erreur lors de l\'actualisation.', error)
|
||||
reject(error)
|
||||
} else {
|
||||
if(response.statusCode === 200){
|
||||
if (response.statusCode === 200) {
|
||||
resolve(body)
|
||||
} else {
|
||||
reject(body)
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {ipcRenderer} = require('electron')
|
||||
const { ipcRenderer } = require('electron')
|
||||
const fs = require('fs-extra')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
@ -16,12 +16,12 @@ ConfigManager.load()
|
||||
// Load Strings
|
||||
LangLoader.loadLanguage('en_US')
|
||||
|
||||
function onDistroLoad(data){
|
||||
if(data != null){
|
||||
function onDistroLoad(data) {
|
||||
if (data != null) {
|
||||
|
||||
// Resolve the selected server if its value has yet to be set.
|
||||
if(ConfigManager.getSelectedServer() == null || data.getServer(ConfigManager.getSelectedServer()) == null){
|
||||
logger.log('Determining default selected server..')
|
||||
if (ConfigManager.getSelectedServer() == null || data.getServer(ConfigManager.getSelectedServer()) == null) {
|
||||
logger.log('Determination du serveur par default..')
|
||||
ConfigManager.setSelectedServer(data.getMainServer().getID())
|
||||
ConfigManager.save()
|
||||
}
|
||||
@ -31,26 +31,26 @@ function onDistroLoad(data){
|
||||
|
||||
// Ensure Distribution is downloaded and cached.
|
||||
DistroManager.pullRemote().then((data) => {
|
||||
logger.log('Loaded distribution index.')
|
||||
logger.log('Index de distribution chargé.')
|
||||
|
||||
onDistroLoad(data)
|
||||
|
||||
}).catch((err) => {
|
||||
logger.log('Failed to load distribution index.')
|
||||
logger.log('Impossible de charger une ancienne version de distribution.')
|
||||
logger.error(err)
|
||||
|
||||
logger.log('Attempting to load an older version of the distribution index.')
|
||||
// Try getting a local copy, better than nothing.
|
||||
DistroManager.pullLocal().then((data) => {
|
||||
logger.log('Successfully loaded an older version of the distribution index.')
|
||||
logger.log('Une ancienne version du fichier de distribution a été chargé avec succes')
|
||||
|
||||
onDistroLoad(data)
|
||||
|
||||
|
||||
}).catch((err) => {
|
||||
|
||||
logger.log('Failed to load an older version of the distribution index.')
|
||||
logger.log('Application cannot run.')
|
||||
logger.log('Impossible de charger une ancienne version de distribution.')
|
||||
logger.log('L\'application de peux pas demaré.')
|
||||
logger.error(err)
|
||||
|
||||
onDistroLoad(null)
|
||||
@ -61,9 +61,9 @@ DistroManager.pullRemote().then((data) => {
|
||||
|
||||
// Clean up temp dir incase previous launches ended unexpectedly.
|
||||
fs.remove(path.join(os.tmpdir(), ConfigManager.getTempNativeFolder()), (err) => {
|
||||
if(err){
|
||||
logger.warn('Error while cleaning natives directory', err)
|
||||
if (err) {
|
||||
logger.warn('Erreur durant le nettoyage du dossier des natives', err)
|
||||
} else {
|
||||
logger.log('Cleaned natives directory.')
|
||||
logger.log('Dossier des natives nettoyé.')
|
||||
}
|
||||
})
|
@ -15,7 +15,7 @@ const logger = LoggerUtil('%c[ProcessBuilder]', 'color: #003996; font-weight: bo
|
||||
|
||||
class ProcessBuilder {
|
||||
|
||||
constructor(distroServer, versionData, forgeData, authUser, launcherVersion){
|
||||
constructor(distroServer, versionData, forgeData, authUser, launcherVersion) {
|
||||
this.gameDir = path.join(ConfigManager.getInstanceDirectory(), distroServer.getID())
|
||||
this.commonDir = ConfigManager.getCommonDirectory()
|
||||
this.server = distroServer
|
||||
@ -35,7 +35,7 @@ class ProcessBuilder {
|
||||
/**
|
||||
* 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
|
||||
@ -44,9 +44,9 @@ class ProcessBuilder {
|
||||
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())){
|
||||
if (!Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())) {
|
||||
this.constructJSONModList('forge', modObj.fMods, true)
|
||||
if(this.usingLiteLoader){
|
||||
if (this.usingLiteLoader) {
|
||||
this.constructJSONModList('liteloader', modObj.lMods, true)
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ class ProcessBuilder {
|
||||
const uberModArr = modObj.fMods.concat(modObj.lMods)
|
||||
let args = this.constructJVMArguments(uberModArr, tempNativePath)
|
||||
|
||||
if(Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())){
|
||||
if (Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())) {
|
||||
//args = args.concat(this.constructModArguments(modObj.fMods))
|
||||
args = args.concat(this.constructModList(modObj.fMods))
|
||||
}
|
||||
@ -66,7 +66,7 @@ class ProcessBuilder {
|
||||
detached: ConfigManager.getLaunchDetached()
|
||||
})
|
||||
|
||||
if(ConfigManager.getLaunchDetached()){
|
||||
if (ConfigManager.getLaunchDetached()) {
|
||||
child.unref()
|
||||
}
|
||||
|
||||
@ -85,10 +85,10 @@ class ProcessBuilder {
|
||||
child.on('close', (code, signal) => {
|
||||
logger.log('Exited with code', code)
|
||||
fs.remove(tempNativePath, (err) => {
|
||||
if(err){
|
||||
logger.warn('Error while deleting temp dir', err)
|
||||
if (err) {
|
||||
logger.warn('Erreur lors de la suppression du répertoire temporaire', err)
|
||||
} else {
|
||||
logger.log('Temp dir deleted successfully.')
|
||||
logger.log('Répertoire temporaire supprimé avec succès.')
|
||||
}
|
||||
})
|
||||
})
|
||||
@ -113,7 +113,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
|
||||
}
|
||||
|
||||
@ -123,19 +123,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()
|
||||
}
|
||||
@ -153,25 +153,25 @@ class ProcessBuilder {
|
||||
* @returns {{fMods: Array.<Object>, lMods: Array.<Object>}} An object which contains
|
||||
* a list of enabled forge mods and litemods.
|
||||
*/
|
||||
resolveModConfiguration(modCfg, mdls){
|
||||
resolveModConfiguration(modCfg, mdls) {
|
||||
let fMods = []
|
||||
let lMods = []
|
||||
|
||||
for(let mdl of mdls){
|
||||
for (let mdl of mdls) {
|
||||
const type = mdl.getType()
|
||||
if(type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader){
|
||||
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()){
|
||||
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){
|
||||
if (mdl.type === DistroManager.Types.LiteLoader) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if(mdl.type === DistroManager.Types.ForgeMod){
|
||||
if (mdl.type === DistroManager.Types.ForgeMod) {
|
||||
fMods.push(mdl)
|
||||
} else {
|
||||
lMods.push(mdl)
|
||||
@ -194,19 +194,19 @@ class ProcessBuilder {
|
||||
* Test to see if this version of forge requires the absolute: prefix
|
||||
* on the modListFile repository field.
|
||||
*/
|
||||
_requiresAbsolute(){
|
||||
_requiresAbsolute() {
|
||||
try {
|
||||
if(this._lteMinorVersion(9)) {
|
||||
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++){
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
const parsed = Number.parseInt(pts[i])
|
||||
if(parsed < min[i]){
|
||||
if (parsed < min[i]) {
|
||||
return false
|
||||
} else if(parsed > min[i]){
|
||||
} else if (parsed > min[i]) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -226,24 +226,24 @@ 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.
|
||||
*/
|
||||
constructJSONModList(type, mods, save = false){
|
||||
constructJSONModList(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){
|
||||
if (type === 'forge') {
|
||||
for (let mod of mods) {
|
||||
ids.push(mod.getExtensionlessID())
|
||||
}
|
||||
} else {
|
||||
for(let mod of mods){
|
||||
for (let mod of mods) {
|
||||
ids.push(mod.getExtensionlessID() + '@' + mod.getExtension())
|
||||
}
|
||||
}
|
||||
modList.modRef = ids
|
||||
|
||||
if(save){
|
||||
if (save) {
|
||||
const json = JSON.stringify(modList, null, 4)
|
||||
fs.writeFileSync(type === 'forge' ? this.fmlDir : this.llDir, json, 'UTF-8')
|
||||
}
|
||||
@ -284,7 +284,7 @@ class ProcessBuilder {
|
||||
return mod.getExtensionlessID()
|
||||
}).join('\n')
|
||||
|
||||
if(writeBuffer) {
|
||||
if (writeBuffer) {
|
||||
fs.writeFileSync(this.forgeModListFile, writeBuffer, 'UTF-8')
|
||||
return [
|
||||
'--fml.mavenRoots',
|
||||
@ -298,12 +298,12 @@ class ProcessBuilder {
|
||||
|
||||
}
|
||||
|
||||
_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)
|
||||
}
|
||||
@ -317,8 +317,8 @@ 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())){
|
||||
constructJVMArguments(mods, tempNativePath) {
|
||||
if (Util.mcVersionAtLeast('1.13', this.server.getMinecraftVersion())) {
|
||||
return this._constructJVMArguments113(mods, tempNativePath)
|
||||
} else {
|
||||
return this._constructJVMArguments112(mods, tempNativePath)
|
||||
@ -333,7 +333,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.
|
||||
*/
|
||||
_constructJVMArguments112(mods, tempNativePath){
|
||||
_constructJVMArguments112(mods, tempNativePath) {
|
||||
|
||||
let args = []
|
||||
|
||||
@ -342,7 +342,7 @@ class ProcessBuilder {
|
||||
args.push(this.classpathArg(mods, tempNativePath).join(process.platform === 'win32' ? ';' : ':'))
|
||||
|
||||
// Java Arguments
|
||||
if(process.platform === 'darwin'){
|
||||
if (process.platform === 'darwin') {
|
||||
args.push('-Xdock:name=HeliosLauncher')
|
||||
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
||||
}
|
||||
@ -370,7 +370,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(mods, tempNativePath) {
|
||||
|
||||
const argDiscovery = /\${*(.*)}/
|
||||
|
||||
@ -380,7 +380,7 @@ class ProcessBuilder {
|
||||
//args.push('-Dlog4j.configurationFile=D:\\WesterosCraft\\game\\common\\assets\\log_configs\\client-1.12.xml')
|
||||
|
||||
// Java Arguments
|
||||
if(process.platform === 'darwin'){
|
||||
if (process.platform === 'darwin') {
|
||||
args.push('-Xdock:name=HeliosLauncher')
|
||||
args.push('-Xdock:icon=' + path.join(__dirname, '..', 'images', 'minecraft.icns'))
|
||||
}
|
||||
@ -394,27 +394,27 @@ class ProcessBuilder {
|
||||
// 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'
|
||||
@ -426,10 +426,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)
|
||||
}
|
||||
@ -440,11 +440,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
|
||||
@ -492,7 +492,7 @@ class ProcessBuilder {
|
||||
val = this.classpathArg(mods, tempNativePath).join(process.platform === 'win32' ? ';' : ':')
|
||||
break
|
||||
}
|
||||
if(val != null){
|
||||
if (val != null) {
|
||||
args[i] = val
|
||||
}
|
||||
}
|
||||
@ -503,15 +503,15 @@ class ProcessBuilder {
|
||||
let isAutoconnectBroken
|
||||
try {
|
||||
isAutoconnectBroken = Util.isAutoconnectBroken(this.forgeData.id.split('-')[2])
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
logger.error('Forge version format changed.. assuming autoconnect works.')
|
||||
logger.error('Le format de la version de Forge a changé ... en supposant que la connexion automatique fonctionne.')
|
||||
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!')
|
||||
if (isAutoconnectBroken) {
|
||||
logger.error('Connexion automatique du serveur désactivée sur Forge 1.15.2 pour les versions antérieures à 31.2.15 en raison d\'un problème d\' OpenGL.')
|
||||
logger.error('Veuillez mettre à jour votre version de Forge au moins au 31.2.15!')
|
||||
} else {
|
||||
this._processAutoConnectArg(args)
|
||||
}
|
||||
@ -533,16 +533,16 @@ class ProcessBuilder {
|
||||
*
|
||||
* @returns {Array.<string>} An array containing the arguments required by forge.
|
||||
*/
|
||||
_resolveForgeArgs(){
|
||||
_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])){
|
||||
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){
|
||||
switch (identifier) {
|
||||
case 'auth_player_name':
|
||||
val = this.authUser.displayName.trim()
|
||||
break
|
||||
@ -575,7 +575,7 @@ class ProcessBuilder {
|
||||
val = this.versionData.type
|
||||
break
|
||||
}
|
||||
if(val != null){
|
||||
if (val != null) {
|
||||
mcArgs[i] = val
|
||||
}
|
||||
}
|
||||
@ -585,7 +585,7 @@ class ProcessBuilder {
|
||||
this._processAutoConnectArg(mcArgs)
|
||||
|
||||
// Prepare game resolution
|
||||
if(ConfigManager.getFullscreen()){
|
||||
if (ConfigManager.getFullscreen()) {
|
||||
mcArgs.push('--fullscreen')
|
||||
mcArgs.push(true)
|
||||
} else {
|
||||
@ -597,7 +597,7 @@ class ProcessBuilder {
|
||||
|
||||
// Mod List File Argument
|
||||
mcArgs.push('--modListFile')
|
||||
if(this._lteMinorVersion(9)) {
|
||||
if (this._lteMinorVersion(9)) {
|
||||
mcArgs.push(path.basename(this.fmlDir))
|
||||
} else {
|
||||
mcArgs.push('absolute:' + this.fmlDir)
|
||||
@ -605,7 +605,7 @@ class ProcessBuilder {
|
||||
|
||||
|
||||
// LiteLoader
|
||||
if(this.usingLiteLoader){
|
||||
if (this.usingLiteLoader) {
|
||||
mcArgs.push('--modRepo')
|
||||
mcArgs.push(this.llDir)
|
||||
|
||||
@ -626,9 +626,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)
|
||||
}
|
||||
}
|
||||
@ -644,14 +644,14 @@ 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(mods, 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){
|
||||
if (this.usingLiteLoader) {
|
||||
cpArgs.push(this.llPath)
|
||||
}
|
||||
|
||||
@ -664,7 +664,7 @@ class ProcessBuilder {
|
||||
// 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}
|
||||
const finalLibs = {...mojangLibs, ...servLibs }
|
||||
cpArgs = cpArgs.concat(Object.values(finalLibs))
|
||||
|
||||
this._processClassPathList(cpArgs)
|
||||
@ -681,15 +681,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) {
|
||||
const libs = {}
|
||||
|
||||
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)
|
||||
@ -707,23 +707,23 @@ class ProcessBuilder {
|
||||
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){
|
||||
logger.error('Error while extracting native library:', err)
|
||||
if (err) {
|
||||
logger.error('Erreur durant l\'extraction de la bibliotheque de native:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -744,30 +744,30 @@ 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){
|
||||
_resolveServerLibraries(mods) {
|
||||
const mdls = this.server.getModules()
|
||||
let libs = {}
|
||||
|
||||
// Locate Forge/Libraries
|
||||
for(let mdl of mdls){
|
||||
for (let mdl of mdls) {
|
||||
const type = mdl.getType()
|
||||
if(type === DistroManager.Types.ForgeHosted || type === DistroManager.Types.Library){
|
||||
if (type === DistroManager.Types.ForgeHosted || type === DistroManager.Types.Library) {
|
||||
libs[mdl.getVersionlessID()] = mdl.getArtifact().getPath()
|
||||
if(mdl.hasSubModules()){
|
||||
if (mdl.hasSubModules()) {
|
||||
const res = this._resolveModuleLibraries(mdl)
|
||||
if(res.length > 0){
|
||||
libs = {...libs, ...res}
|
||||
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){
|
||||
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}
|
||||
if (res.length > 0) {
|
||||
libs = {...libs, ...res }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -781,20 +781,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)
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ function setLaunchEnabled(val) {
|
||||
|
||||
// Bind launch button
|
||||
document.getElementById('launch_button').addEventListener('click', function(e) {
|
||||
loggerLanding.log('Launching game..')
|
||||
loggerLanding.log('Lancement du jeu..')
|
||||
const mcVersion = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer()).getMinecraftVersion()
|
||||
const jExe = ConfigManager.getJavaExecutable()
|
||||
if (jExe == null) {
|
||||
@ -98,7 +98,7 @@ document.getElementById('launch_button').addEventListener('click', function(e) {
|
||||
|
||||
const jg = new JavaGuard(mcVersion)
|
||||
jg._validateJavaBinary(jExe).then((v) => {
|
||||
loggerLanding.log('Java version meta', v)
|
||||
loggerLanding.log('Version de la donnée de meta de Java', v)
|
||||
if (v.valid) {
|
||||
dlAsync()
|
||||
} else {
|
||||
@ -124,7 +124,7 @@ document.getElementById('avatarOverlay').onclick = (e) => {
|
||||
|
||||
// Bind selected account
|
||||
function updateSelectedAccount(authUser) {
|
||||
let username = 'No Account Selected'
|
||||
let username = 'Aucun compte selectionné'
|
||||
if (authUser != null) {
|
||||
if (authUser.displayName != null) {
|
||||
username = authUser.displayName
|
||||
@ -144,7 +144,7 @@ function updateSelectedServer(serv) {
|
||||
}
|
||||
ConfigManager.setSelectedServer(serv != null ? serv.getID() : null)
|
||||
ConfigManager.save()
|
||||
server_selection_button.innerHTML = '\u2022 ' + (serv != null ? serv.getName() : 'No Server Selected')
|
||||
server_selection_button.innerHTML = '\u2022 ' + (serv != null ? serv.getName() : 'Aucun serveur selecionné')
|
||||
if (getCurrentView() === VIEWS.settings) {
|
||||
animateModsTabRefresh()
|
||||
}
|
||||
@ -159,7 +159,7 @@ server_selection_button.onclick = (e) => {
|
||||
|
||||
// Update Mojang Status Color
|
||||
const refreshMojangStatuses = async function() {
|
||||
loggerLanding.log('Refreshing Mojang Statuses..')
|
||||
loggerLanding.log('Rafraichissement des status de Mojang..')
|
||||
|
||||
let status = 'grey'
|
||||
let tooltipEssentialHTML = ''
|
||||
@ -212,7 +212,7 @@ const refreshMojangStatuses = async function() {
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
loggerLanding.warn('Unable to refresh Mojang service status.')
|
||||
loggerLanding.warn('Impossible d\'actualiser l\'état du service Mojang. ')
|
||||
loggerLanding.debug(err)
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ const refreshMojangStatuses = async function() {
|
||||
}
|
||||
|
||||
const refreshServerStatus = async function(fade = false) {
|
||||
loggerLanding.log('Refreshing Server Status')
|
||||
loggerLanding.log('Actualisation de l\'état du serveur')
|
||||
const serv = DistroManager.getDistribution().getServer(ConfigManager.getSelectedServer())
|
||||
|
||||
let pLabel = 'SERVER'
|
||||
@ -237,7 +237,7 @@ const refreshServerStatus = async function(fade = false) {
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
loggerLanding.warn('Unable to refresh server status, assuming offline.')
|
||||
loggerLanding.warn('Impossible d\'actualiser l\'état du serveur, en supposant qu\'il est hors ligne.')
|
||||
loggerLanding.debug(err)
|
||||
}
|
||||
if (fade) {
|
||||
@ -270,7 +270,7 @@ function showLaunchFailure(title, desc) {
|
||||
setOverlayContent(
|
||||
title,
|
||||
desc,
|
||||
'Okay'
|
||||
'Ok'
|
||||
)
|
||||
setOverlayHandler(null)
|
||||
toggleOverlay(true)
|
||||
@ -470,7 +470,7 @@ function asyncSystemScan(mcVersion, launchAfter = true) {
|
||||
})
|
||||
|
||||
// Begin system Java scan.
|
||||
setLaunchDetails('Checking system info..')
|
||||
setLaunchDetails('Vérification des informations système..')
|
||||
sysAEx.send({ task: 'execute', function: 'validateJava', argsArr: [ConfigManager.getDataDirectory()] })
|
||||
|
||||
}
|
||||
@ -650,8 +650,8 @@ function dlAsync(login = true) {
|
||||
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.')
|
||||
loggerLaunchSuite.error('Erreur lors du lancement', m.result.error)
|
||||
showLaunchFailure('Erreur lors du lancement', 'Veuillez vérifier la console (CTRL + Shift + i) pour plus de détails.')
|
||||
|
||||
allGood = false
|
||||
}
|
||||
@ -661,17 +661,17 @@ function dlAsync(login = true) {
|
||||
|
||||
if (login && allGood) {
|
||||
const authUser = ConfigManager.getSelectedAccount()
|
||||
loggerLaunchSuite.log(`Sending selected account (${authUser.displayName}) to ProcessBuilder.`)
|
||||
loggerLaunchSuite.log(`Envoi du compte sélectionné (${authUser.displayName}) à ProcessBuilder.`)
|
||||
let pb = new ProcessBuilder(serv, versionData, forgeData, authUser, remote.app.getVersion())
|
||||
setLaunchDetails('Launching game..')
|
||||
setLaunchDetails('Lancement du jeu..')
|
||||
|
||||
// const SERVER_JOINED_REGEX = /\[.+\]: \[CHAT\] [a-zA-Z0-9_]{1,16} joined the game/
|
||||
const SERVER_JOINED_REGEX = new RegExp(`\\[.+\\]: \\[CHAT\\] ${authUser.displayName} joined the game`)
|
||||
const SERVER_JOINED_REGEX = new RegExp(`\\[.+\\]: \\[CHAT\\] ${authUser.displayName} rejoint le jeu`)
|
||||
|
||||
const onLoadComplete = () => {
|
||||
toggleLaunchArea(false)
|
||||
if (hasRPC) {
|
||||
DiscordWrapper.updateDetails('Loading game..')
|
||||
DiscordWrapper.updateDetails('Jeu en cours de chargement..')
|
||||
}
|
||||
proc.stdout.on('data', gameStateChange)
|
||||
proc.stdout.removeListener('data', tempListener)
|
||||
@ -879,7 +879,7 @@ let newsLoadingListener = null
|
||||
*/
|
||||
function setNewsLoading(val) {
|
||||
if (val) {
|
||||
const nLStr = 'Checking for News'
|
||||
const nLStr = 'Vérification des actualités'
|
||||
let dotStr = '..'
|
||||
nELoadSpan.innerHTML = nLStr + dotStr
|
||||
newsLoadingListener = setInterval(() => {
|
||||
|
@ -4,7 +4,7 @@
|
||||
// Validation Regexes.
|
||||
const validUsername = /^[a-zA-Z0-9_]{1,16}$/
|
||||
const basicEmail = /^\S+@\S+\.\S+$/
|
||||
//const validEmail = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i
|
||||
//const validEmail = /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i
|
||||
|
||||
// Login Elements
|
||||
const loginCancelContainer = document.getElementById('loginCancelContainer')
|
||||
@ -19,7 +19,8 @@ const loginButton = document.getElementById('loginButton')
|
||||
const loginForm = document.getElementById('loginForm')
|
||||
|
||||
// Control variables.
|
||||
let lu = false, lp = false
|
||||
let lu = false,
|
||||
lp = false
|
||||
|
||||
const loggerLogin = LoggerUtil('%c[Login]', 'color: #000668; font-weight: bold')
|
||||
|
||||
@ -30,7 +31,7 @@ const loggerLogin = LoggerUtil('%c[Login]', 'color: #000668; font-weight: bold')
|
||||
* @param {HTMLElement} element The element on which to display the error.
|
||||
* @param {string} value The error text.
|
||||
*/
|
||||
function showError(element, value){
|
||||
function showError(element, value) {
|
||||
element.innerHTML = value
|
||||
element.style.opacity = 1
|
||||
}
|
||||
@ -40,8 +41,8 @@ function showError(element, value){
|
||||
*
|
||||
* @param {HTMLElement} element The element to shake.
|
||||
*/
|
||||
function shakeError(element){
|
||||
if(element.style.opacity == 1){
|
||||
function shakeError(element) {
|
||||
if (element.style.opacity == 1) {
|
||||
element.classList.remove('shake')
|
||||
void element.offsetWidth
|
||||
element.classList.add('shake')
|
||||
@ -53,16 +54,16 @@ function shakeError(element){
|
||||
*
|
||||
* @param {string} value The email value.
|
||||
*/
|
||||
function validateEmail(value){
|
||||
if(value){
|
||||
if(!basicEmail.test(value) && !validUsername.test(value)){
|
||||
function validateEmail(value) {
|
||||
if (value) {
|
||||
if (!basicEmail.test(value) && !validUsername.test(value)) {
|
||||
showError(loginEmailError, Lang.queryJS('login.error.invalidValue'))
|
||||
loginDisabled(true)
|
||||
lu = false
|
||||
} else {
|
||||
loginEmailError.style.opacity = 0
|
||||
lu = true
|
||||
if(lp){
|
||||
if (lp) {
|
||||
loginDisabled(false)
|
||||
}
|
||||
}
|
||||
@ -78,11 +79,11 @@ function validateEmail(value){
|
||||
*
|
||||
* @param {string} value The password value.
|
||||
*/
|
||||
function validatePassword(value){
|
||||
if(value){
|
||||
function validatePassword(value) {
|
||||
if (value) {
|
||||
loginPasswordError.style.opacity = 0
|
||||
lp = true
|
||||
if(lu){
|
||||
if (lu) {
|
||||
loginDisabled(false)
|
||||
}
|
||||
} else {
|
||||
@ -115,8 +116,8 @@ loginPassword.addEventListener('input', (e) => {
|
||||
*
|
||||
* @param {boolean} v True to enable, false to disable.
|
||||
*/
|
||||
function loginDisabled(v){
|
||||
if(loginButton.disabled !== v){
|
||||
function loginDisabled(v) {
|
||||
if (loginButton.disabled !== v) {
|
||||
loginButton.disabled = v
|
||||
}
|
||||
}
|
||||
@ -126,8 +127,8 @@ function loginDisabled(v){
|
||||
*
|
||||
* @param {boolean} v True to enable, false to disable.
|
||||
*/
|
||||
function loginLoading(v){
|
||||
if(v){
|
||||
function loginLoading(v) {
|
||||
if (v) {
|
||||
loginButton.setAttribute('loading', v)
|
||||
loginButton.innerHTML = loginButton.innerHTML.replace(Lang.queryJS('login.login'), Lang.queryJS('login.loggingIn'))
|
||||
} else {
|
||||
@ -141,12 +142,12 @@ function loginLoading(v){
|
||||
*
|
||||
* @param {boolean} v True to enable, false to disable.
|
||||
*/
|
||||
function formDisabled(v){
|
||||
function formDisabled(v) {
|
||||
loginDisabled(v)
|
||||
loginCancelButton.disabled = v
|
||||
loginUsername.disabled = v
|
||||
loginPassword.disabled = v
|
||||
if(v){
|
||||
if (v) {
|
||||
checkmarkContainer.setAttribute('disabled', v)
|
||||
} else {
|
||||
checkmarkContainer.removeAttribute('disabled')
|
||||
@ -161,24 +162,24 @@ function formDisabled(v){
|
||||
* @param {Error | {cause: string, error: string, errorMessage: string}} err A Node.js
|
||||
* error or Mojang error response.
|
||||
*/
|
||||
function resolveError(err){
|
||||
function resolveError(err) {
|
||||
// Mojang Response => err.cause | err.error | err.errorMessage
|
||||
// Node error => err.code | err.message
|
||||
if(err.cause != null && err.cause === 'UserMigratedException') {
|
||||
if (err.cause != null && err.cause === 'UserMigratedException') {
|
||||
return {
|
||||
title: Lang.queryJS('login.error.userMigrated.title'),
|
||||
desc: Lang.queryJS('login.error.userMigrated.desc')
|
||||
}
|
||||
} else {
|
||||
if(err.error != null){
|
||||
if(err.error === 'ForbiddenOperationException'){
|
||||
if(err.errorMessage != null){
|
||||
if(err.errorMessage === 'Invalid credentials. Invalid username or password.'){
|
||||
if (err.error != null) {
|
||||
if (err.error === 'ForbiddenOperationException') {
|
||||
if (err.errorMessage != null) {
|
||||
if (err.errorMessage === 'invalidCredentials') {
|
||||
return {
|
||||
title: Lang.queryJS('login.error.invalidCredentials.title'),
|
||||
desc: Lang.queryJS('login.error.invalidCredentials.desc')
|
||||
}
|
||||
} else if(err.errorMessage === 'Invalid credentials.'){
|
||||
} else if (err.errorMessage === 'invalidCredentials') {
|
||||
return {
|
||||
title: Lang.queryJS('login.error.rateLimit.title'),
|
||||
desc: Lang.queryJS('login.error.rateLimit.desc')
|
||||
@ -188,14 +189,14 @@ function resolveError(err){
|
||||
}
|
||||
} else {
|
||||
// Request errors (from Node).
|
||||
if(err.code != null){
|
||||
if(err.code === 'ENOENT'){
|
||||
if (err.code != null) {
|
||||
if (err.code === 'ENOENT') {
|
||||
// No Internet.
|
||||
return {
|
||||
title: Lang.queryJS('login.error.noInternet.title'),
|
||||
desc: Lang.queryJS('login.error.noInternet.desc')
|
||||
}
|
||||
} else if(err.code === 'ENOTFOUND'){
|
||||
} else if (err.code === 'ENOTFOUND') {
|
||||
// Could not reach server.
|
||||
return {
|
||||
title: Lang.queryJS('login.error.authDown.title'),
|
||||
@ -205,8 +206,8 @@ function resolveError(err){
|
||||
}
|
||||
}
|
||||
}
|
||||
if(err.message != null){
|
||||
if(err.message === 'NotPaidAccount'){
|
||||
if (err.message != null) {
|
||||
if (err.message === 'NotPaidAccount') {
|
||||
return {
|
||||
title: Lang.queryJS('login.error.notPaid.title'),
|
||||
desc: Lang.queryJS('login.error.notPaid.desc')
|
||||
@ -231,8 +232,8 @@ let loginViewOnSuccess = VIEWS.landing
|
||||
let loginViewOnCancel = VIEWS.settings
|
||||
let loginViewCancelHandler
|
||||
|
||||
function loginCancelEnabled(val){
|
||||
if(val){
|
||||
function loginCancelEnabled(val) {
|
||||
if (val) {
|
||||
$(loginCancelContainer).show()
|
||||
} else {
|
||||
$(loginCancelContainer).hide()
|
||||
@ -244,7 +245,7 @@ loginCancelButton.onclick = (e) => {
|
||||
loginUsername.value = ''
|
||||
loginPassword.value = ''
|
||||
loginCancelEnabled(false)
|
||||
if(loginViewCancelHandler != null){
|
||||
if (loginViewCancelHandler != null) {
|
||||
loginViewCancelHandler()
|
||||
loginViewCancelHandler = null
|
||||
}
|
||||
@ -270,7 +271,7 @@ loginButton.addEventListener('click', () => {
|
||||
setTimeout(() => {
|
||||
switchView(VIEWS.login, loginViewOnSuccess, 500, 500, () => {
|
||||
// Temporary workaround
|
||||
if(loginViewOnSuccess === VIEWS.settings){
|
||||
if (loginViewOnSuccess === VIEWS.settings) {
|
||||
prepareSettings()
|
||||
}
|
||||
loginViewOnSuccess = VIEWS.landing // Reset this for good measure.
|
||||
@ -294,7 +295,7 @@ loginButton.addEventListener('click', () => {
|
||||
toggleOverlay(false)
|
||||
})
|
||||
toggleOverlay(true)
|
||||
loggerLogin.log('Error while logging in.', err)
|
||||
loggerLogin.log('Erreur lors de la connexion.', err)
|
||||
})
|
||||
|
||||
})
|
@ -36,7 +36,7 @@ let currentView
|
||||
* @param {*} onNextFade Optional. Callback function to execute when the next view
|
||||
* fades in.
|
||||
*/
|
||||
function switchView(current, next, currentFadeTime = 500, nextFadeTime = 500, onCurrentFade = () => {}, onNextFade = () => {}){
|
||||
function switchView(current, next, currentFadeTime = 500, nextFadeTime = 500, onCurrentFade = () => {}, onNextFade = () => {}) {
|
||||
currentView = next
|
||||
$(`${current}`).fadeOut(currentFadeTime, () => {
|
||||
onCurrentFade()
|
||||
@ -51,14 +51,14 @@ function switchView(current, next, currentFadeTime = 500, nextFadeTime = 500, on
|
||||
*
|
||||
* @returns {string} The currently shown view container.
|
||||
*/
|
||||
function getCurrentView(){
|
||||
function getCurrentView() {
|
||||
return currentView
|
||||
}
|
||||
|
||||
function showMainUI(data){
|
||||
function showMainUI(data) {
|
||||
|
||||
if(!isDev){
|
||||
loggerAutoUpdater.log('Initializing..')
|
||||
if (!isDev) {
|
||||
loggerAutoUpdater.log('Initialisation..')
|
||||
ipcRenderer.send('autoUpdateAction', 'initAutoUpdater', ConfigManager.getAllowPrerelease())
|
||||
}
|
||||
|
||||
@ -74,15 +74,15 @@ function showMainUI(data){
|
||||
|
||||
// If this is enabled in a development environment we'll get ratelimited.
|
||||
// The relaunch frequency is usually far too high.
|
||||
if(!isDev && isLoggedIn){
|
||||
if (!isDev && isLoggedIn) {
|
||||
validateSelectedAccount()
|
||||
}
|
||||
|
||||
if(ConfigManager.isFirstLaunch()){
|
||||
if (ConfigManager.isFirstLaunch()) {
|
||||
currentView = VIEWS.welcome
|
||||
$(VIEWS.welcome).fadeIn(1000)
|
||||
} else {
|
||||
if(isLoggedIn){
|
||||
if (isLoggedIn) {
|
||||
currentView = VIEWS.landing
|
||||
$(VIEWS.landing).fadeIn(1000)
|
||||
} else {
|
||||
@ -104,14 +104,14 @@ function showMainUI(data){
|
||||
})
|
||||
}
|
||||
|
||||
function showFatalStartupError(){
|
||||
function showFatalStartupError() {
|
||||
setTimeout(() => {
|
||||
$('#loadingContainer').fadeOut(250, () => {
|
||||
document.getElementById('overlayContainer').style.background = 'none'
|
||||
setOverlayContent(
|
||||
'Fatal Error: Unable to Load Distribution Index',
|
||||
'A connection could not be established to our servers to download the distribution index. No local copies were available to load. <br><br>The distribution index is an essential file which provides the latest server information. The launcher is unable to start without it. Ensure you are connected to the internet and relaunch the application.',
|
||||
'Close'
|
||||
'Erreur fatale: impossible de charger l\'index de distribution',
|
||||
'Une connexion n\'a pas pu être établie avec nos serveurs pour télécharger l\'index de distribution. Aucune copie locale n\'était disponible pour le chargement. <br> <br> L\'index de distribution est un fichier essentiel qui fournit les dernières informations sur le serveur. Le lanceur ne peut pas démarrer sans lui. Assurez-vous que vous êtes connecté à Internet et relancez l\'application.',
|
||||
'Fermer'
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
const window = remote.getCurrentWindow()
|
||||
@ -127,7 +127,7 @@ function showFatalStartupError(){
|
||||
*
|
||||
* @param {Object} data The distro index object.
|
||||
*/
|
||||
function onDistroRefresh(data){
|
||||
function onDistroRefresh(data) {
|
||||
updateSelectedServer(data.getServer(ConfigManager.getSelectedServer()))
|
||||
refreshServerStatus()
|
||||
initNews()
|
||||
@ -139,38 +139,38 @@ function onDistroRefresh(data){
|
||||
*
|
||||
* @param {Object} data The distro index object.
|
||||
*/
|
||||
function syncModConfigurations(data){
|
||||
function syncModConfigurations(data) {
|
||||
|
||||
const syncedCfgs = []
|
||||
|
||||
for(let serv of data.getServers()){
|
||||
for (let serv of data.getServers()) {
|
||||
|
||||
const id = serv.getID()
|
||||
const mdls = serv.getModules()
|
||||
const cfg = ConfigManager.getModConfiguration(id)
|
||||
|
||||
if(cfg != null){
|
||||
if (cfg != null) {
|
||||
|
||||
const modsOld = cfg.mods
|
||||
const mods = {}
|
||||
|
||||
for(let mdl of mdls){
|
||||
for (let mdl of mdls) {
|
||||
const type = mdl.getType()
|
||||
|
||||
if(type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader){
|
||||
if(!mdl.getRequired().isRequired()){
|
||||
if (type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader) {
|
||||
if (!mdl.getRequired().isRequired()) {
|
||||
const mdlID = mdl.getVersionlessID()
|
||||
if(modsOld[mdlID] == null){
|
||||
if (modsOld[mdlID] == null) {
|
||||
mods[mdlID] = scanOptionalSubModules(mdl.getSubModules(), mdl)
|
||||
} else {
|
||||
mods[mdlID] = mergeModConfiguration(modsOld[mdlID], scanOptionalSubModules(mdl.getSubModules(), mdl), false)
|
||||
}
|
||||
} else {
|
||||
if(mdl.hasSubModules()){
|
||||
if (mdl.hasSubModules()) {
|
||||
const mdlID = mdl.getVersionlessID()
|
||||
const v = scanOptionalSubModules(mdl.getSubModules(), mdl)
|
||||
if(typeof v === 'object'){
|
||||
if(modsOld[mdlID] == null){
|
||||
if (typeof v === 'object') {
|
||||
if (modsOld[mdlID] == null) {
|
||||
mods[mdlID] = v
|
||||
} else {
|
||||
mods[mdlID] = mergeModConfiguration(modsOld[mdlID], v, true)
|
||||
@ -190,15 +190,15 @@ function syncModConfigurations(data){
|
||||
|
||||
const mods = {}
|
||||
|
||||
for(let mdl of mdls){
|
||||
for (let mdl of mdls) {
|
||||
const type = mdl.getType()
|
||||
if(type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader){
|
||||
if(!mdl.getRequired().isRequired()){
|
||||
if (type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader) {
|
||||
if (!mdl.getRequired().isRequired()) {
|
||||
mods[mdl.getVersionlessID()] = scanOptionalSubModules(mdl.getSubModules(), mdl)
|
||||
} else {
|
||||
if(mdl.hasSubModules()){
|
||||
if (mdl.hasSubModules()) {
|
||||
const v = scanOptionalSubModules(mdl.getSubModules(), mdl)
|
||||
if(typeof v === 'object'){
|
||||
if (typeof v === 'object') {
|
||||
mods[mdl.getVersionlessID()] = v
|
||||
}
|
||||
}
|
||||
@ -225,21 +225,21 @@ function syncModConfigurations(data){
|
||||
*
|
||||
* @returns {boolean | Object} The resolved mod configuration.
|
||||
*/
|
||||
function scanOptionalSubModules(mdls, origin){
|
||||
if(mdls != null){
|
||||
function scanOptionalSubModules(mdls, origin) {
|
||||
if (mdls != null) {
|
||||
const mods = {}
|
||||
|
||||
for(let mdl of mdls){
|
||||
for (let mdl of mdls) {
|
||||
const type = mdl.getType()
|
||||
// Optional types.
|
||||
if(type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader){
|
||||
if (type === DistroManager.Types.ForgeMod || type === DistroManager.Types.LiteMod || type === DistroManager.Types.LiteLoader) {
|
||||
// It is optional.
|
||||
if(!mdl.getRequired().isRequired()){
|
||||
if (!mdl.getRequired().isRequired()) {
|
||||
mods[mdl.getVersionlessID()] = scanOptionalSubModules(mdl.getSubModules(), mdl)
|
||||
} else {
|
||||
if(mdl.hasSubModules()){
|
||||
if (mdl.hasSubModules()) {
|
||||
const v = scanOptionalSubModules(mdl.getSubModules(), mdl)
|
||||
if(typeof v === 'object'){
|
||||
if (typeof v === 'object') {
|
||||
mods[mdl.getVersionlessID()] = v
|
||||
}
|
||||
}
|
||||
@ -247,11 +247,11 @@ function scanOptionalSubModules(mdls, origin){
|
||||
}
|
||||
}
|
||||
|
||||
if(Object.keys(mods).length > 0){
|
||||
if (Object.keys(mods).length > 0) {
|
||||
const ret = {
|
||||
mods
|
||||
}
|
||||
if(!origin.getRequired().isRequired()){
|
||||
if (!origin.getRequired().isRequired()) {
|
||||
ret.value = origin.getRequired().isDefault()
|
||||
}
|
||||
return ret
|
||||
@ -269,27 +269,27 @@ function scanOptionalSubModules(mdls, origin){
|
||||
*
|
||||
* @returns {boolean | Object} The merged configuration.
|
||||
*/
|
||||
function mergeModConfiguration(o, n, nReq = false){
|
||||
if(typeof o === 'boolean'){
|
||||
if(typeof n === 'boolean') return o
|
||||
else if(typeof n === 'object'){
|
||||
if(!nReq){
|
||||
function mergeModConfiguration(o, n, nReq = false) {
|
||||
if (typeof o === 'boolean') {
|
||||
if (typeof n === 'boolean') return o
|
||||
else if (typeof n === 'object') {
|
||||
if (!nReq) {
|
||||
n.value = o
|
||||
}
|
||||
return n
|
||||
}
|
||||
} else if(typeof o === 'object'){
|
||||
if(typeof n === 'boolean') return typeof o.value !== 'undefined' ? o.value : true
|
||||
else if(typeof n === 'object'){
|
||||
if(!nReq){
|
||||
} else if (typeof o === 'object') {
|
||||
if (typeof n === 'boolean') return typeof o.value !== 'undefined' ? o.value : true
|
||||
else if (typeof n === 'object') {
|
||||
if (!nReq) {
|
||||
n.value = typeof o.value !== 'undefined' ? o.value : true
|
||||
}
|
||||
|
||||
const newMods = Object.keys(n.mods)
|
||||
for(let i=0; i<newMods.length; i++){
|
||||
for (let i = 0; i < newMods.length; i++) {
|
||||
|
||||
const mod = newMods[i]
|
||||
if(o.mods[mod] != null){
|
||||
if (o.mods[mod] != null) {
|
||||
n.mods[mod] = mergeModConfiguration(o.mods[mod], n.mods[mod])
|
||||
}
|
||||
}
|
||||
@ -302,8 +302,8 @@ function mergeModConfiguration(o, n, nReq = false){
|
||||
return n
|
||||
}
|
||||
|
||||
function refreshDistributionIndex(remote, onSuccess, onError){
|
||||
if(remote){
|
||||
function refreshDistributionIndex(remote, onSuccess, onError) {
|
||||
if (remote) {
|
||||
DistroManager.pullRemote()
|
||||
.then(onSuccess)
|
||||
.catch(onError)
|
||||
@ -314,26 +314,26 @@ function refreshDistributionIndex(remote, onSuccess, onError){
|
||||
}
|
||||
}
|
||||
|
||||
async function validateSelectedAccount(){
|
||||
async function validateSelectedAccount() {
|
||||
const selectedAcc = ConfigManager.getSelectedAccount()
|
||||
if(selectedAcc != null){
|
||||
if (selectedAcc != null) {
|
||||
const val = await AuthManager.validateSelected()
|
||||
if(!val){
|
||||
if (!val) {
|
||||
ConfigManager.removeAuthAccount(selectedAcc.uuid)
|
||||
ConfigManager.save()
|
||||
const accLen = Object.keys(ConfigManager.getAuthAccounts()).length
|
||||
setOverlayContent(
|
||||
'Failed to Refresh Login',
|
||||
`We were unable to refresh the login for <strong>${selectedAcc.displayName}</strong>. Please ${accLen > 0 ? 'select another account or ' : ''} login again.`,
|
||||
'Login',
|
||||
'Select Another Account'
|
||||
'Échec de l\'actualisation de la connexion',
|
||||
`Nous n'avons pas pu actualiser la connexion pour <strong>${selectedAcc.displayName}</strong>. Merci ${accLen > 0 ? 'sélectionnez un autre compte ou ' : ''} reconnectez-vous.`,
|
||||
'Connection',
|
||||
'Sélectionnez un autre compte'
|
||||
)
|
||||
setOverlayHandler(() => {
|
||||
document.getElementById('loginUsername').value = selectedAcc.username
|
||||
validateEmail(selectedAcc.username)
|
||||
loginViewOnSuccess = getCurrentView()
|
||||
loginViewOnCancel = getCurrentView()
|
||||
if(accLen > 0){
|
||||
if (accLen > 0) {
|
||||
loginViewCancelHandler = () => {
|
||||
ConfigManager.addAuthAccount(selectedAcc.uuid, selectedAcc.accessToken, selectedAcc.username, selectedAcc.displayName)
|
||||
ConfigManager.save()
|
||||
@ -345,7 +345,7 @@ async function validateSelectedAccount(){
|
||||
switchView(getCurrentView(), VIEWS.login)
|
||||
})
|
||||
setDismissHandler(() => {
|
||||
if(accLen > 1){
|
||||
if (accLen > 1) {
|
||||
prepareAccountSelectionList()
|
||||
$('#overlayContent').fadeOut(250, () => {
|
||||
bindOverlayKeys(true, 'accountSelectContent', true)
|
||||
@ -374,7 +374,7 @@ async function validateSelectedAccount(){
|
||||
*
|
||||
* @param {string} uuid The UUID of the account.
|
||||
*/
|
||||
function setSelectedAccount(uuid){
|
||||
function setSelectedAccount(uuid) {
|
||||
const authAcc = ConfigManager.setSelectedAccount(uuid)
|
||||
ConfigManager.save()
|
||||
updateSelectedAccount(authAcc)
|
||||
@ -382,12 +382,12 @@ function setSelectedAccount(uuid){
|
||||
}
|
||||
|
||||
// Synchronous Listener
|
||||
document.addEventListener('readystatechange', function(){
|
||||
document.addEventListener('readystatechange', function() {
|
||||
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete'){
|
||||
if(rscShouldLoad){
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
if (rscShouldLoad) {
|
||||
rscShouldLoad = false
|
||||
if(!fatalStartupError){
|
||||
if (!fatalStartupError) {
|
||||
const data = DistroManager.getDistribution()
|
||||
showMainUI(data)
|
||||
} else {
|
||||
@ -400,17 +400,17 @@ document.addEventListener('readystatechange', function(){
|
||||
|
||||
// Actions that must be performed after the distribution index is downloaded.
|
||||
ipcRenderer.on('distributionIndexDone', (event, res) => {
|
||||
if(res) {
|
||||
if (res) {
|
||||
const data = DistroManager.getDistribution()
|
||||
syncModConfigurations(data)
|
||||
if(document.readyState === 'interactive' || document.readyState === 'complete'){
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
showMainUI(data)
|
||||
} else {
|
||||
rscShouldLoad = true
|
||||
}
|
||||
} else {
|
||||
fatalStartupError = true
|
||||
if(document.readyState === 'interactive' || document.readyState === 'complete'){
|
||||
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
||||
showFatalStartupError()
|
||||
} else {
|
||||
rscShouldLoad = true
|
||||
|
Loading…
Reference in New Issue
Block a user