Skip to content

Commit

Permalink
Add a few flags to cli & disable everybody-op by default? (#634)
Browse files Browse the repository at this point in the history
* add a few shortcuts & disable op by default?

* its false only in my fork

* reprhase descriptions

* seems got the problem
  • Loading branch information
zardoy authored Dec 31, 2023
1 parent cb3cfd0 commit 9e3fafd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
31 changes: 22 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion config/default-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
1 change: 1 addition & 0 deletions test/mineflayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e3fafd

Please sign in to comment.