feat(informer): 🚸 add sub-command for module level quiet

master
jay 3 years ago
parent e879d1f4ad
commit 050e2b3bd9
  1. 16
      lib/plugins/informer.js

@ -18,12 +18,12 @@ function block(pos) {
const block = pos ? bot.blockAt(v(pos)) : bot.blockAtCursor()
console.log(block, block && block.getProperties())
if (!block) {
cfg.quiet || bot.chat("empty block")
quiet || bot.chat("empty block")
return block
}
let info = [block.type, block.name]
if (block.metadata) info.push(Object.entries(block.getProperties()))
cfg.quiet || bot.chat(info.join(": "))
quiet || bot.chat(info.join(": "))
}
function item(
@ -35,7 +35,7 @@ function item(
entity.heldItem
console.log(item)
if (!item) {
cfg.quiet || bot.chat("no item")
quiet || bot.chat("no item")
return item
}
let info = [item.type, item.name]
@ -43,7 +43,7 @@ function item(
if (item.nbt) {
info.push(compound_value(item.nbt))
}
cfg.quiet || bot.chat(info.join("; "))
quiet || bot.chat(info.join("; "))
function compound_value(obj) {
if (typeof obj.value == "object") {
return compound_value(obj.value)
@ -68,13 +68,13 @@ function entity(name) {
}) : entity
console.log(entity)
if (!entity) {
cfg.quiet || bot.chat("no entity")
quiet || bot.chat("no entity")
return entity
}
let info = [entity.type, entity.username || entity.name]
// TODO various info depending on the type of entity; player, villager, etc
if (entity.metadata) info.push("len: " + entity.metadata.length)
cfg.quiet || bot.chat(info.join("; "))
quiet || bot.chat(info.join("; "))
return entity
}
@ -94,6 +94,10 @@ function command(message_parts, player) {
break;
case 1:
switch (message_parts[0]) {
case "quiet":
cfg.info.quiet = quiet = !quiet;
quiet || bot.chat(`info: ${quiet ? "" : "not "}being quiet`);
break;
case "i":
case "item":
item()

Loading…
Cancel
Save