flying-squid/src/lib/plugins/weather.js
2018-05-13 09:26:48 -04:00

24 lines
685 B
JavaScript

module.exports.player = function (player, serv) {
player.commands.add({
base: 'weather',
info: 'Sets the weather.',
usage: '/weather <clear|rain>',
op: true,
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})
}
}
})
}