27 lines
No EOL
780 B
JavaScript
27 lines
No EOL
780 B
JavaScript
const { literal } = require('brigadier-commands')
|
|
|
|
module.exports = {
|
|
register (dispatcher) {
|
|
const node = dispatcher.register(
|
|
literal('randomteleport')
|
|
.executes(c => this.randomTeleportCommand(c))
|
|
)
|
|
|
|
dispatcher.register(literal('rtp').executes(c => this.randomTeleportCommand(c)).redirect(node))
|
|
|
|
node.description = 'Teleports the sender to a random location'
|
|
node.permissionLevel = 0
|
|
},
|
|
|
|
randomTeleportCommand (context) {
|
|
const source = context.source
|
|
const bot = source.bot
|
|
const player = source.getPlayerOrThrow()
|
|
|
|
bot.core.run(`tp ${player.uuid} ${randomInt(-30000000, 30000000)} 256 ${randomInt(-30000000, 30000000)}`)
|
|
}
|
|
}
|
|
|
|
function randomInt (min, max) {
|
|
return Math.floor((Math.random() * (max - min)) + min)
|
|
} |