diff --git a/app.js b/app.js index c166a03a..9cf707fc 100755 --- a/app.js +++ b/app.js @@ -9,26 +9,39 @@ const argv = require('yargs/yargs')(process.argv.slice(2)) 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') +const defaultSettings = require('./config/default-settings.json') let settings try { - settings = require(`${argv.config}/settings`) - - Object.keys(defaultSettings).forEach(settingKey => { - if (settings[settingKey] === undefined) { - settings[settingKey] = defaultSettings[settingKey] - } - }) + settings = require(`${argv.config}/settings.json`) } catch (err) { - settings = defaultSettings + 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 => { diff --git a/config/default-settings.json b/config/default-settings.json index e7d05524..3b57ee3f 100644 --- a/config/default-settings.json +++ b/config/default-settings.json @@ -23,7 +23,7 @@ "header":{"text": "Flying squid"}, "footer":{"text": "Test server"} }, - "everybody-op":true, + "everybody-op": false, "max-entities":100, "version": "1.16.1" } diff --git a/test/mineflayer.test.js b/test/mineflayer.test.js index d1b2bfcc..968f7de8 100644 --- a/test/mineflayer.test.js +++ b/test/mineflayer.test.js @@ -50,6 +50,7 @@ squid.supportedVersions.forEach((supportedVersion, i) => { beforeEach(async () => { const options = settings options['online-mode'] = false + options['everybody-op'] = true options.port = 0 options['view-distance'] = 2 options.worldFolder = undefined