feat(command): temp. move inventory chat handling to command

This is temporary, and only the `toss` function.
Old functionality is still intact.
New code will eventually move back as a subcommand to replace the old.
cover
jay 3 years ago
parent e9f2080556
commit f2281a7cb3
  1. 68
      lib/plugins/command.js
  2. 2
      lib/plugins/inventory.js

@ -426,29 +426,51 @@ function command(username, message) {
// case "take": // case "take":
// // TODO take only what's requested, then throw all the rest // // TODO take only what's requested, then throw all the rest
// // TODO take all // // TODO take all
// case "toss":
// case "drop": // TODO move subcommands to cfg.plugins.inventory.itemByName
// if (!message_parts[1]) { return false } // FIXME, works but ugly case "toss":
// if (!checkItemExists(message_parts[1])) { return false } case "drop":
// switch (message_parts.length) { if (!message_parts[1]) { return false } // FIXME, works but ugly
// case 2: // TODO use cfg.plugins.inventory.itemByName
// bot.toss(mcData.blocksByName[message_parts[1]].id) const item = cfg.plugins.inventory.itemByName(message_parts[1])
// break if (!mcData.findItemOrBlockByName(message_parts[1])) {
// case 3: console.log("doesn't exist:", message_parts[1])
// bot.tossStack( cfg.quiet || bot.chat(`item doesn't exist: ${message_parts[1]}`)
// mcData.itemsByName[message_parts[1]].id, return false
// (err) => { } else if (!item) {
// if (err) { console.log("don't have:", message_parts[1])
// console.log(err) cfg.quiet || bot.chat(`don't have item: ${message_parts[1]}`)
// bot.chat(err) }
// } switch (message_parts.length) {
// } case 2:
// ) bot.tossStack(
// break item,
// default: (err) => {
// break if (err) {
// } console.error(err)
// break; cfg.quiet || bot.chat(err.message)
}
}
)
break
case 3:
const amount = parseInt(message_parts[2])
bot.toss(
item.type,
null, //metadata
amount,
(err) => {
if (err) {
console.error(err)
cfg.quiet || bot.chat(err.message)
}
}
)
break
default:
break
}
break;
case "location": case "location":
// TODO put in /lib/location // TODO put in /lib/location
switch (message_parts[1]) { switch (message_parts[1]) {

@ -225,4 +225,4 @@ const unload = () => {
bot.off('chat', inventory) bot.off('chat', inventory)
} }
module.exports = { load, unload, equipItem, craftItem } module.exports = { load, unload, equipItem, craftItem, itemByName }
Loading…
Cancel
Save