This commit is contained in:
Pierce 2019-01-12 21:39:22 -05:00
parent 4202eb201c
commit 2b6fa2a973
4 changed files with 10 additions and 6 deletions

3
components/events.js Normal file
View file

@ -0,0 +1,3 @@
const event = require('events');
module.exports = new event.EventEmitter();

View file

@ -1,4 +1,5 @@
const child = require('child_process'); const child = require('child_process');
const event = require('./events');
const path = require('path'); const path = require('path');
const handler = require('./handler'); const handler = require('./handler');
const fs = require('fs'); const fs = require('fs');
@ -53,8 +54,8 @@ module.exports = async function (options) {
const arguments = args.concat(memory, jvm, classPaths, launchOptions); const arguments = args.concat(memory, jvm, classPaths, launchOptions);
const minecraft = child.spawn("java", arguments); const minecraft = child.spawn("java", arguments);
event.emit('start', null);
minecraft.stdout.on('data', (data) => {console.log(`[Minecraft] ${data}`)}); minecraft.stdout.on('data', (data) => event.emit('data', data));
minecraft.stderr.on('data', (data) => {console.error(`[Error] ${data}`)}); minecraft.stderr.on('data', (data) => event.emit('error', data));
minecraft.on('close', (code) => {console.log(`Minecraft closed with code ${code}`)}); minecraft.on('close', (code) => event.emit('close', code));
}; };

View file

@ -1,6 +1,6 @@
module.exports = { module.exports = {
core: require('./components/launcher'), core: require('./components/launcher'),
event: require('./components/events'),
handler: require('./components/handler'), handler: require('./components/handler'),
authenticator: require('./components/authenticator'), authenticator: require('./components/authenticator'),
}; };

View file

@ -1,6 +1,6 @@
{ {
"name": "minecraft-launcher-core", "name": "minecraft-launcher-core",
"version": "1.0.6", "version": "1.1.0",
"description": "Module that downloads Minecraft assets and runs Minecraft.", "description": "Module that downloads Minecraft assets and runs Minecraft.",
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {