flying-squid/src/lib/plugins/weather.js
2021-04-21 18:59:44 +02:00

24 lines
718 B
JavaScript
Executable file

module.exports.player = function (player, serv) {
player.commands.add({
base: 'weather',
info: 'Sets the weather.',
usage: '/weather <clear|rain>',
permission: "world.changeWeather",
parse (str) {
const args = str.split(' ')
if (args.length !== 1) { return false }
let condition = args[0]
if (['clear', 'rain'].indexOf(condition) === -1) { return false }
return { condition: condition }
},
action ({ condition }) {
if (condition === 'rain') {
serv._writeAll('game_state_change', { reason: 2, gameMode: 0 })
} else if (condition === 'clear') {
serv._writeAll('game_state_change', { reason: 1, gameMode: 0 })
}
}
})
}