From b0864da791dc1aa6cd11fa32d4b0fadfd3c7cad3 Mon Sep 17 00:00:00 2001 From: OverloadedWolf Date: Fri, 29 Apr 2016 17:26:50 -0400 Subject: [PATCH] Weather Command Created the base for the weather command. Currently it will give an warning if you do not have enough parameters to fulfill the command. It will, however, crash the server when used properly. --- src/lib/plugins/weather.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/lib/plugins/weather.js diff --git a/src/lib/plugins/weather.js b/src/lib/plugins/weather.js new file mode 100644 index 0000000..8d5ccfb --- /dev/null +++ b/src/lib/plugins/weather.js @@ -0,0 +1,29 @@ + +module.exports.player = function(player, serv) { // Player is a type of entity (entity inject is called first) with added properties and functions + player.commands.add({ + base: 'weather', + info: 'Sets ths weather.', + usage: '/weather [duration]', + op: true, + parse(str) { + const args = str.split(' '); + if(args.length!=2) + return false; + + let condition = player.selectorString(args[0]); + if(condition.length==0) throw new UserError("one condition"); + + let duration = player.selectorString(args[1]); + if(duration.length < 1) throw new UserError("one duration"); + + return {condition:condition[0],duration:duration[0]}; + }, + action({condition,duration}){ + if(condition == 'rain'){ + serv._writeAll('game_state_change',{reason:2,value:0}); + } else if(condition == 'clear') { + serv._writeAll('game_state_change',{reason:1,value:0}); + } + } + }) +};