28 lines
922 B
JavaScript
28 lines
922 B
JavaScript
const { literal, argument, greedyString } = require('brigadier-commands')
|
|
const { createNameSelector } = require('../util/command/utility')
|
|
|
|
module.exports = {
|
|
register (dispatcher) {
|
|
const node = dispatcher.register(
|
|
literal('hole')
|
|
.then(
|
|
argument('targets', greedyString())
|
|
.executes(c => this.holeCommand(c))
|
|
)
|
|
)
|
|
|
|
node.description = 'Creates a hole at the position of a players'
|
|
node.permissionLevel = 0
|
|
},
|
|
|
|
holeCommand (context) {
|
|
const source = context.source
|
|
const bot = source.bot
|
|
|
|
let selector = context.getArgument('targets')
|
|
const selector0 = selector[0]
|
|
if (selector0 !== '@' && selector0 !== '"' && selector0 !== "'" && selector.includes(' ')) selector = createNameSelector(selector)
|
|
|
|
bot.core.run(`execute at ${selector} run setblock ~ 1 ~ command_block{Command:'fill ~-1 0 ~-1 ~1 255 ~1 air destroy',auto:1b}`)
|
|
}
|
|
}
|