Files
mc-bot-town/nodejs/controller/tp.js
2025-05-04 19:22:31 -04:00

46 lines
821 B
JavaScript

'use strict';
const conf = require('../conf');
const {sleep} = require('../utils');
class Tp{
constructor(args){
this.bot = args.bot;
}
async init(){
for(let pluginName in this.bot.plunginsLoaded){
if(this.bot.plunginsLoaded[pluginName].isDangerous){
this.bot.pluginUnload(pluginName);
this.pluginToContinue = pluginName;
}
}
let spot = this.bot.findBlockBySign('bot TP spot');
if(spot){
await this.bot.goTo({
where: spot,
range: 1,
});
}
this.cleatTimeout = setTimeout(()=>{
this.bot.pluginUnload(this.constructor.name)
}, 60000);
}
unload(){
if(this.cleatTimeout){
clearTimeout(this.cleatTimeout);
this.cleatTimeout = undefined;
}
if(this.pluginToContinue) this.bot.pluginLoad(this.pluginToContinue);
return true;
}
}
module.exports = Tp;