storage
This commit is contained in:
@@ -30,6 +30,45 @@ module.exports = {
|
||||
'.trade': {
|
||||
desc: 'Bot will take trade requests',
|
||||
async function(from){
|
||||
// Check if bot has StoragePlugin
|
||||
if (this.plunginsLoaded['Storage']) {
|
||||
// Storage bot flow
|
||||
await this.say('/trade accept');
|
||||
let window = await this.once('windowOpen');
|
||||
|
||||
// Collect items received from player
|
||||
const itemsReceived = [];
|
||||
const customerSlots = [5, 6, 7, 8, 14, 15, 16, 17, 23, 24, 25, 26];
|
||||
|
||||
for (const slotNum of customerSlots) {
|
||||
const item = window.slots[slotNum];
|
||||
if (item) {
|
||||
itemsReceived.push({
|
||||
name: item.name,
|
||||
id: item.type,
|
||||
count: item.count,
|
||||
nbt: item.nbt
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm and log trade
|
||||
this.bot.moveSlotItem(37, 37);
|
||||
|
||||
// Wait for trade to complete
|
||||
await this.once('windowClose');
|
||||
|
||||
// Handle the trade items
|
||||
if (itemsReceived.length > 0) {
|
||||
await this.plunginsLoaded['Storage'].handleTrade(from, itemsReceived);
|
||||
this.whisper(from, `Received ${itemsReceived.length} item type(s). Sorting into storage.`);
|
||||
} else {
|
||||
this.whisper(from, `No items received.`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Original sign-based flow for non-storage bots
|
||||
/*
|
||||
todo
|
||||
|
||||
|
||||
Reference in New Issue
Block a user