plugins
This commit is contained in:
53
nodejs/controller/guardianFarm.js
Normal file
53
nodejs/controller/guardianFarm.js
Normal file
@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
const conf = require('../conf');
|
||||
const {sleep, nextTick} = require('../utils');
|
||||
|
||||
class GuardianFarm{
|
||||
constructor(args){
|
||||
this.bot = args.bot;
|
||||
this.isDangerous = true;
|
||||
this.isAction = true;
|
||||
}
|
||||
|
||||
async init(){
|
||||
console.log('GuardianFarm started')
|
||||
this.onReadyListen = this.bot.on('onReady', async ()=>{
|
||||
await sleep(3000);
|
||||
let lastTimeListen = this.bot.bot.time.timeOfDay;
|
||||
this.onTimeListen = this.bot.bot.on('time', async ()=>{
|
||||
let isDay = lastTimeListen < this.bot.bot.time.timeOfDay;
|
||||
lastTimeListen = this.bot.bot.time.timeOfDay;
|
||||
|
||||
if(isDay){
|
||||
await this.onNewDay();
|
||||
}
|
||||
});
|
||||
await this.bot.pluginLoad('Swing');
|
||||
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unload(){
|
||||
this.onReadyListen();
|
||||
this.onTimeListen();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async onNewDay(){
|
||||
try{
|
||||
console.log('GuardianFarm.onNewDay new day!');
|
||||
await this.bot.pluginUnload('Swing');
|
||||
await this.bot.pluginLoad('Craft');
|
||||
await this.bot.pluginUnload('Craft');
|
||||
await this.bot.pluginLoad('Swing');
|
||||
}catch(error){
|
||||
console.error('Error in GuardianFarm.onNewDay:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GuardianFarm;
|
Reference in New Issue
Block a user