const path = require('path') const {AssetGuard} = require(path.join(__dirname, 'assets', 'js', 'assetguard.js')) const ProcessBuilder = require(path.join(__dirname, 'assets', 'js', 'processbuilder.js')) const ConfigManager = require(path.join(__dirname, 'assets', 'js', 'configmanager.js')) const DiscordWrapper = require(path.join(__dirname, 'assets', 'js', 'discordwrapper.js')) const Mojang = require(path.join(__dirname, 'assets', 'js', 'mojang.js')) const AuthManager = require(path.join(__dirname, 'assets', 'js', 'authmanager.js')) let mojangStatusListener // Synchronous Listener document.addEventListener('readystatechange', function(){ if (document.readyState === 'interactive'){ // Bind launch button document.getElementById('launch_button').addEventListener('click', function(e){ console.log('Launching game..') testdownloads() }) // TODO convert this to dropdown menu. // Bind selected server document.getElementById('server_selection').innerHTML = '\u2022 ' + AssetGuard.getServerById(ConfigManager.getGameDirectory(), ConfigManager.getSelectedServer()).name // Update Mojang Status Color const refreshMojangStatuses = async function(){ console.log('Refreshing Mojang Statuses..') try { let status = 'grey' const statuses = await Mojang.status() greenCount = 0 for(let i=0; i -1){ details.style.display = 'none' content.style.display = 'inline-flex' proc.stdout.removeListener('data', tempListener) } } proc.stdout.on('data', tempListener) // Init Discord Hook (Untested) const distro = AssetGuard.retrieveDistributionDataSync(ConfigManager.getGameDirectory) if(distro.discord != null && serv.discord != null){ DiscordWrapper.initRPC(distro.discord, serv.discord) proc.on('close', (code, signal) => { DiscordWrapper.shutdownRPC() }) } } catch(err) { //det_text.innerHTML = 'Error: ' + err.message; det_text.innerHTML = 'Error: See log for details..'; console.log(err) setTimeout(function(){ details.style.display = 'none' content.style.display = 'inline-flex' }, 5000) } // Remove reference to tracker. tracker = null }) tracker.processDlQueues() }