refactor(command): ♻️ make toss exit early if non-existent block

This commit is contained in:
jay 2020-12-27 00:30:46 +05:00
parent 5b4718fa5d
commit ba7c53be0c

View File

@ -431,13 +431,13 @@ function command(username, message) {
case "toss": case "toss":
case "drop": case "drop":
if (!message_parts[1]) { return false } // FIXME, works but ugly if (!message_parts[1]) { return false } // FIXME, works but ugly
// TODO use cfg.plugins.inventory.itemByName
const item = cfg.plugins.inventory.itemByName(message_parts[1])
if (!mcData.findItemOrBlockByName(message_parts[1])) { if (!mcData.findItemOrBlockByName(message_parts[1])) {
console.log("doesn't exist:", message_parts[1]) console.log("doesn't exist:", message_parts[1])
cfg.quiet || bot.chat(`item doesn't exist: ${message_parts[1]}`) cfg.quiet || bot.chat(`item doesn't exist: ${message_parts[1]}`)
return false return false
} else if (!item) { }
const item = cfg.plugins.inventory.itemByName(message_parts[1])
if (!item) {
console.log("don't have:", message_parts[1]) console.log("don't have:", message_parts[1])
cfg.quiet || bot.chat(`don't have item: ${message_parts[1]}`) cfg.quiet || bot.chat(`don't have item: ${message_parts[1]}`)
return false return false