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

This commit is contained in:
jay 2021-05-07 12:53:24 +05:00
parent e879d1f4ad
commit 050e2b3bd9

View File

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