@boem312/minecraft-server
Version:
A pure JS library to create Minecraft Java 1.16.3 servers
38 lines (33 loc) • 1.26 kB
JavaScript
const CustomError = require('../../../../CustomError.js');
module.exports = {
raining: {
info: {
defaultable: true,
defaultSetTime: 'afterLogin'
},
get() {
return this.p._raining;
},
set(newValue, beforeReady) {
if ((!beforeReady) && (!this.p.stateHandler.checkReady.call(this)))
return;
if (typeof newValue !== 'boolean')
this.p.emitError(new CustomError('expectationNotMet', 'libraryUser', `raining in <${this.constructor.name}>.raining = ${require('util').inspect(newValue)} `, {
got: newValue,
expectationType: 'type',
expectation: 'boolean'
}, null, { server: this.server, client: this }));
const oldValue = this.raining;
this.p._raining = newValue;
this.p.sendPacket('game_state_change', {
reason: 7,
gameMode: this.raining ? this.toxicRainLevel + 1 : 0
});
if ((!beforeReady) && oldValue !== newValue)
this.p.emitChange('raining', oldValue);
},
init() {
this.p._raining = false;
}
}
}