-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
56 lines (52 loc) · 1.63 KB
/
Copy pathindex.js
File metadata and controls
56 lines (52 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*******************************************************
* Copyright (C) 2016 Kaiden Prince me@kaienprince.com
*
* This file is part of IronWatt.
*
* IronWatt can not be copied and/or distributed, in part
* or in whole, without the express written permission of Kaiden Prince,
* Unless otherwise specified in the License file, bundled with this
* application
*******************************************************/
"use strict";
const d = require("debug")("IronWatt:main"),
fs = require('fs'),
util = require("./src/util"),
Minecraft = require("./src/proxy")
d("IronWatt Started")
d("Loading Config")
let mc;
require("./src/conf").readConf().on("load", () => {
d("Config loaded!")
if (conf.minecraft.autoDownload) {
util.minecraft.downloadServerAuto(next)
} else next()
function next() {
let jarName = conf.minecraft.getJarName()
fs.stat(jarName, (err, stats) => {
if (err && err.code === "ENOENT") {
new Error(`Minecraft jar ${jarName} not found`)
} else if (!err) {
if (stats.isFile()) {
// All good, can now run
mc = new Minecraft()
d("starting Minecraft")
mc.start()
} else {
throw new Error(`${jarName} is not a file`)
}
} else {
throw err
}
})
}
})
const readline = require('readline');
let rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
rl.on('line', function (line) {
mc.writeLine(line)
})