-
Notifications
You must be signed in to change notification settings - Fork 100
/
app.js
executable file
·49 lines (41 loc) · 1.16 KB
/
app.js
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
#!/usr/bin/env node
const argv = require('yargs/yargs')(process.argv.slice(2))
.usage('Usage: $0 <command> [options]')
.help('h')
.option('config', {
alias: 'c',
type: 'string',
default: './config',
description: 'Configuration directory'
})
.option('offline', {
type: 'boolean',
default: 'false'
})
.option('log', {
description: 'Enable logging: When true create a log file in the logs folder',
type: 'boolean',
default: 'true'
})
.option('op', {
description: 'Useful for testing. When specified, op every player (give administrative permissions)',
type: 'boolean',
default: 'false'
})
.argv
const mcServer = require('./')
const defaultSettings = require('./config/default-settings.json')
let settings
try {
settings = require(`${argv.config}/settings.json`)
} catch (err) {
settings = {}
}
settings = Object.assign(settings, defaultSettings, settings)
if (argv.offline) settings['online-mode'] = false
if (argv.log) settings.logging = true
if (argv.op) settings['everybody-op'] = true
module.exports = mcServer.createMCServer(settings)
process.on('unhandledRejection', err => {
console.log(err.stack)
})