screepsmod-admin-utils
Version:
## This is a Collection of utilities for Screeps Private Server admins
28 lines (25 loc) • 1.1 kB
JavaScript
module.exports = (config) => {
const { common: { storage: { env } } } = config
config.utils.on('config:update:map', async (urlOrMapId) => {
const currentMap = await env.get(env.keys.MAP_URL)
if (currentMap) {
if (currentMap !== urlOrMapId) {
console.log(`Map value in config.yml has changed to ${urlOrMapId}, current map is ${currentMap}`)
console.log(`If you wish to apply this then call utils.importMap('${urlOrMapId}') manually or system.resetAllData() then restart server.`)
}
return
}
await config.utils.importMap(urlOrMapId)
})
config.utils.on('config:update:mapFile', async (filePath) => {
const currentMap = await env.get(env.keys.MAP_URL)
if (currentMap) {
if (currentMap !== filePath) {
console.log(`Map value in config.yml has changed to ${filePath}, current map is ${currentMap}`)
console.log(`If you wish to apply this then call utils.importMapFile('${filePath}') manually or system.resetAllData() then restart server.`)
}
return
}
await config.utils.importMapFile(filePath)
})
}