forked from wmantly/mc-bot-town
storage
This commit is contained in:
106
nodejs/controller/commands/storage.js
Normal file
106
nodejs/controller/commands/storage.js
Normal file
@@ -0,0 +1,106 @@
|
||||
'use strict';
|
||||
|
||||
// Owner players who can run admin commands
|
||||
const owners = ['wmantly', 'useless666', 'tux4242'];
|
||||
// Team players who can use basic storage features
|
||||
const team = [...owners, 'pi_chef', 'Ethan', 'Vince_NL'];
|
||||
|
||||
module.exports = {
|
||||
'scan': {
|
||||
desc: 'Force chest area scan',
|
||||
allowed: owners,
|
||||
ignoreLock: true,
|
||||
async function(from) {
|
||||
console.log(`Storage command 'scan' from ${from}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'scan');
|
||||
}
|
||||
},
|
||||
'status': {
|
||||
desc: 'Show storage stats',
|
||||
allowed: team,
|
||||
async function(from) {
|
||||
console.log(`Storage command 'status' from ${from}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'status');
|
||||
}
|
||||
},
|
||||
'withdraw': {
|
||||
desc: 'Withdraw items from storage',
|
||||
allowed: team,
|
||||
async function(from, itemName, countStr) {
|
||||
console.log(`Storage command 'withdraw' from ${from}: ${itemName} x${countStr}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
const count = parseInt(countStr) || 1;
|
||||
await storage.handleCommand(from, 'withdraw', itemName, count);
|
||||
}
|
||||
},
|
||||
'find': {
|
||||
desc: 'Search for an item',
|
||||
allowed: team,
|
||||
async function(from, itemName) {
|
||||
console.log(`Storage command 'find' from ${from}: ${itemName}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'find', itemName);
|
||||
}
|
||||
},
|
||||
'chests': {
|
||||
desc: 'List tracked chests',
|
||||
allowed: owners,
|
||||
ignoreLock: true,
|
||||
async function(from) {
|
||||
console.log(`Storage command 'chests' from ${from}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'chests');
|
||||
}
|
||||
},
|
||||
'organize': {
|
||||
desc: 'Force full re-sort',
|
||||
allowed: owners,
|
||||
ignoreLock: true,
|
||||
async function(from) {
|
||||
console.log(`Storage command 'organize' from ${from}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'organize');
|
||||
}
|
||||
},
|
||||
'addplayer': {
|
||||
desc: 'Add player to storage',
|
||||
allowed: owners,
|
||||
ignoreLock: true,
|
||||
async function(from, name, role = 'team') {
|
||||
console.log(`Storage command 'addplayer' from ${from}: ${name} as ${role}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'addplayer', name, role);
|
||||
}
|
||||
},
|
||||
'removeplayer': {
|
||||
desc: 'Remove player from storage',
|
||||
allowed: owners,
|
||||
ignoreLock: true,
|
||||
async function(from, name) {
|
||||
console.log(`Storage command 'removeplayer' from ${from}: ${name}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'removeplayer', name);
|
||||
}
|
||||
},
|
||||
'players': {
|
||||
desc: 'List authorized players',
|
||||
allowed: owners,
|
||||
ignoreLock: true,
|
||||
async function(from) {
|
||||
console.log(`Storage command 'players' from ${from}`);
|
||||
const storage = this.plunginsLoaded['Storage'];
|
||||
if (!storage) return this.whisper(from, 'Storage plugin not loaded');
|
||||
await storage.handleCommand(from, 'players');
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user