Compare commits

...

1 commit

Author SHA1 Message Date
33bc3c9f6f Push older files 2023-06-26 23:04:54 -04:00
154 changed files with 2742 additions and 7904 deletions

View file

@ -1,2 +0,0 @@
# chipmunkbot-archive
Archive of ChipmunkBot, a [kaboom](https://kaboom.pw) bot from 2022 (before the rewrite). The code should run with all modules installed, however, continue at your own risk, as the bot has a (sandboxed) public eval command, the security of which cannot be guaranteed. The bot's current chat parser is known to be broken on modern minecraft servers.

19
ban.js Normal file
View file

@ -0,0 +1,19 @@
const name = 'exploit'
const description = 'Uses exploits.'
const usage = '{prefix}exploit'
const aliases = ['exploit']
const enabled = true
const permLevel = 0
function execute(bot, cmd, player, args, handler) {
const exploit = args.shift()
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: 'Attempting exploit ', color: bot.colors.primary },
{ text: exploit, color: bot.colors.secondary },
'.'
])}`)
bot.exploits[exploit](args.join(' '))
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

179
bot.js
View file

@ -1,139 +1,114 @@
const mc = require('minecraft-protocol')
const { states } = mc
const { EventEmitter } = require('events')
const fs = require('fs')
const path = require('path')
const randomUsername = require('./util/random-username.js')
function createBot (options = {}) {
// defaults
options.username ??= 'Bot'
// options.password = options.password ?? null
options.prefix ??= '!'
options.isBukkit ??= false
options.isKaboom ??= false
options.isScissors ??= false
function createBots(servers = ['localhost'], options = {}) {
const bots = []
servers.forEach((server) => {
const a = server.split(':')
options.host = a[0]
options.port = parseInt(a[1])
options.brand = a[2]
options.plugins ??= {}
fs.readdirSync(
'plugins'
).forEach(filename => { // populate plugins array
if (typeof require.extensions[path.extname(filename)] && options.plugins[filename] == null) {
options.plugins[filename] = require(path.resolve('plugins', filename))
}
})
const plugins = []
Object.keys(options.plugins).forEach((key) => {
const plugin = options.plugins[key]
if (plugin) plugins.push(plugin)
const bot = createBot({ ...options })
bot.getBots = () => bots
bots.push(bot)
})
return bots
}
options.colors ??= {}
options.colors.primary ??= 'white'
options.colors.secondary ??= 'green'
options.autoReconnect ??= false
options.autoReconnectDelay ??= 1000
options.randomizeUsername ??= false
options['online-mode'] ??= {}
options['online-mode'].enabled ??= false
options['online-mode'].username ??= null
options['online-mode'].password ??= null
options['online-mode'].auth ??= 'mojang'
const clientOptions = { // TODO: More options
connect: options.connect,
host: options.server.host,
port: options.server.port,
version: options.version,
username: options['online-mode'].enabled ? options['online-mode'].username : options.username,
password: options['online-mode'].enabled ? options['online-mode'].username : null,
auth: options['online-mode'].enabled ? options['online-mode'].auth : null
}
function createBot(options = {}) {
options.username = options.username ?? 'Bot'
//options.password = options.password ?? null
options.prefix = options.prefix ?? '!'
options.brand = options.brand ?? 'vanilla' //found that mineflayer has this so i added it here lol
options.colors = options.colors ?? { primary: 'white', secondary: 'gray', error: 'red' }
options.autoReconnect = options.autoReconnect ?? true
options.randomizeUsername = options.randomizeUsername ?? true
if (options.randomizeUsername) {
clientOptions.username += randomUsername()
options.username += `§${String.fromCharCode(Math.floor(Math.random() * 65535))}`
}
if (options['online-mode']?.enabled) {
options.username = options['online-mode'].username
options.password = options['online-mode'].password
}
// actually create the bot
const bot = new EventEmitter()
bot.plugins = plugins
bot.loadPlugin = loadPlugin
let bot = new EventEmitter()
// add some properties to the bot
bot.server = options.server
/* bot._client.on('set_protocol', (packet) => {
bot._client = options.client ?? mc.createClient(options)
bot.host = options.host
bot.port = options.port
bot._client.on('set_protocol', (packet) => {
bot.host = packet.serverHost
bot.port = packet.serverPort
}) */
})
//bot.username = () => bot._client.username
//bot.uuid = () => bot._client.uuid
bot.prefix = options.prefix
bot.brand = options.brand
bot.colors = options.colors
bot.autoReconnect = options.autoReconnect
bot.randomizeUsername = options.randomizeUsername
bot['online-mode'] = options['online-mode']
// set the client and add listeners
bot.on('set_client', (client) => {
client.on('connect', () => bot.emit('connect'))
client.on('error', (err) => bot.emit('error', err))
bot.disconnect = reason => bot._client.end(reason)
bot.end = reason => {
bot.autoReconnect = false
bot.disconnect()
const plugins = []
fs.readdirSync(
path.join(__dirname, 'plugins')
).forEach((file) => { // populate plugins array
if (file.endsWith(".js")) {
plugins.push(path.join(__dirname, 'plugins', file));
}
client.on('end', (reason) => {
})
setup(bot)
function setup(bot) {
bot.removeAllListeners() // clean up the bot
bot._client.on('connect', () => bot.emit('connect'))
bot._client.on('error', (err) => bot.emit('error', err))
bot.on('error', console.error)
bot.end = () => bot._client.end()
bot._client.on('end', (reason) => {
bot.loggedIn = false
bot.emit('disconnect', reason)
// auto reconnect
if (bot.autoReconnect) {
setTimeout(() => {
if (bot.randomizeUsername && !bot['online-mode'].enabled) clientOptions.username = randomUsername()
bot.emit('end', reason)
setTimeout(() => {
if (bot.randomizeUsername && bot['online-mode']?.enabled)
options.username = `${options.username.slice(0, -2)}§${String.fromCharCode(Math.floor(Math.random() * 65535))}`
bot._client = mc.createClient(clientOptions)
bot.emit('set_client', bot._client)
}, options.autoReconnectDelay)
} else {
bot.emit('end', reason)
}
bot._client = options.client ?? mc.createClient(options)
setup(bot)
}, 6000)
})
// more event listeners
bot._client.on('state', state => {
bot.state = state
bot.emit('state', state)
//amogus
bot.loggedIn = false
bot._client.on('login', () => {
bot.loggedIn = true
bot.emit('login')
})
bot._client.on('login', data => bot.emit('login', data))
// plugin injection
bot.plugins.forEach(plugin => {
if (typeof plugin.client === 'function') plugin.client(bot, options)
bot.position = { x: null, y: null, z: null } //to prevent errors i guess
bot._client.on('position', (position) => bot.position = position)
plugins.forEach((plugin) => {
loadPlugin(plugin)
})
})
bot._client = options.client ?? mc.createClient(clientOptions)
bot.emit('set_client', bot._client)
}
bot.on('login', () => {
bot.username = bot._client.username
bot.uuid = bot._client.uuid
})
bot.plugins.forEach(plugin => {
if (typeof plugin.bot === 'function') plugin.bot(bot, options)
})
function loadPlugin (plugin) {
function loadPlugin(plugin) {
try {
if (typeof plugin.bot === 'function') plugin.bot(bot, options)
if (typeof plugin.client === 'function') plugin.client(bot, options)
bot.plugins.push(plugin)
} catch (err) {
require(plugin)(bot)
} catch (e) {
console.log(`Error loading ${plugin}:`)
console.log(err)
console.log(require('util').inspect(e))
}
}
bot.loadPlugin = loadPlugin
return bot
}
module.exports = createBot
module.exports = { createBot, createBots }

View file

@ -1,14 +1,16 @@
const fs = require('fs')
const path = require('path')
const cperms = require('./cperms2.js')
const cperms = require('./cperms.js')
let commands = {}
commands = {}
function addCommand (command) {
if (!isValid(command)) throw new Error(`Command ${command} is invalid.`)
if (commands[command] == null) { commands[command] = command }
if (!isValid(command))
return//throw new Error(`Command ${command} is invalid.`)
if (commands[command] == null)
commands[command] = command
command.aliases.forEach((alias) => {
alias = alias.toLowerCase()
if (commands[alias] == null) commands[alias] = command
@ -19,8 +21,8 @@ function load () {
fs.readdirSync(
path.join(__dirname, 'commands')
).forEach((file) => {
if (file.endsWith('.js')) {
const command = path.join(__dirname, 'commands', file)
if (file.endsWith(".js")) {
const command = path.join(__dirname, 'commands', file)
try {
const cmd = require(command)
addCommand(cmd)
@ -32,11 +34,11 @@ function load () {
})
}
function reload () {
function reload() {
try {
Object.keys(commands).forEach(key => {
const command = commands[key]
delete require.cache[command.path]
const command = commands[key];
delete require.cache[command.path];
})
} catch (err) { }
commands = {}
@ -45,31 +47,29 @@ function reload () {
function execute (bot, command, player, args, ...custom) {
const cmd = info(command)
if (!cmd.enabled) { return bot.core.run(`/bcraw &cThe command ${bot.prefix}${command} is disabled.`) }
if (!cmd.enabled)
return bot.core.run(`/bcraw &cThe command ${bot.prefix}${command} is disabled.`)
if (cmd.permLevel > 0) {
if (args.length < 1) {
bot.core.run('/bcraw &cYou must provide a code to run this command.')
return
}
const code = args.splice(-1, 1)[0].replace(/\u00a7.?/g, '')
if (!cperms.validate(cmd.permLevel, player.name, code)) {
bot.core.run(`/tellraw @a ${JSON.stringify([
if (args.length < 1)
return bot.core.run(`/bcraw &cYou must provide a code to run this command.`)
const code = parseFloat(args.splice(-1, 1)[0].replace(/§./g, ''))
if (!cperms.validate(cmd.permLevel, code))
return bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: `Invalid code: ${code}.`, color: bot.colors.error }
])}`)
return
}
}
try {
return cmd.execute(bot, command, player, args, module.exports, ...custom)
} catch (err) {
} catch (e) {
console.log(`Error executing command ${command}:`)
console.log(err)
console.log(require('util').inspect(e))
bot.core.run(`/tellraw @a ${JSON.stringify({ text: err.message, color: bot.colors.error })}`)
bot.core.run(`/tellraw @a ${JSON.stringify({ text: e.stack.split('\n')[0], color: bot.colors.error })}`)
}
}
@ -81,7 +81,7 @@ function isCommand (command) {
return commands[command] != null
}
function isValid (command) {
function isValid(command) {
return command != null &&
typeof command.execute === 'function' &&
typeof command.name === 'string' &&
@ -93,4 +93,4 @@ function isValid (command) {
typeof command.permLevel === 'number'
}
module.exports = { addCommand, load, reload, execute, info, isCommand, isValid, commands }
module.exports = { addCommand, load, reload, execute, info, isCommand, isValid, commands }

View file

@ -1,16 +0,0 @@
const name = '_eval'
const description = 'disabled command, ignore'
const usages = ['<code...>']
const aliases = ['_eval']
const enabled = false
const permLevel = 2
const { inspect } = require('util')
function execute (bot, cmd, player, args, handler) {
const result = eval(args.join(' ').replace(/\xa7.?/g, ''))
console.log(inspect(result)) // bot.core.run('minecraft:tellraw @a ' + JSON.stringify({ text: inspect(result), color: bot.colors.primary }))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,13 +0,0 @@
const name = 'actionbar'
const description = 'exists for some reason'
const usages = ['<message...>']
const aliases = ['actionbar']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
const text = args.join(' ')
bot.core.run('minecraft:title @a actionbar ' + JSON.stringify({ text }))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,36 +0,0 @@
const name = 'antitnt'
const description = 'Prevents explosions'
const usages = [
'on',
'off'
]
const aliases = ['antitnt', 'antiexplosion']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args) {
function sendState () {
bot.tellraw([{ text: 'antiTNT is now ', color: bot.colors.primary }, { text: bot.antiTNT.enabled ? 'on' : 'off', color: bot.colors.secondary }])
}
const subCommand = args.shift()
if (subCommand === undefined) {
throw new Error('ok')
return
}
switch (subCommand.toLowerCase()) {
case 'on':
bot.antiTNT.enabled = true
sendState()
break
case 'off':
bot.antiTNT.enabled = false
sendState()
break
default:
throw new Error('ok')
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

23
commands/badapple.js Normal file
View file

@ -0,0 +1,23 @@
const name = 'badapple'
const description = 'Plays a badapple video.'
const usages = ['[stop]']
const aliases = ['badapple']
const enabled = true
const permLevel = 0
function execute(bot, cmd, player, args, handler) {
if (args[0] === 'stop') {
bot.video.stop()
bot.music.skip()
return
}
bot.video.summon(player.UUID, (uuids) => {
bot.music.stop()
bot.music.queue.push('./music/badapple.mid')
bot.video.play('./videos/badapple.txt', uuids)
})
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

45
commands/blacklist.js Normal file
View file

@ -0,0 +1,45 @@
const name = 'blacklist'
const description = 'idk'
const usages = [
'add <pattern> <flags>',
'remove <pattern> <flags>',
'list'
]
const aliases = ['blacklist']
const enabled = true
const permLevel = 1
function execute(bot, cmd, player, args, handler) {
const subCmd = args.shift()
switch(subCmd) {
case 'add':
bot.blacklist.push([args[0], args[1]])
bot.core.run(`minecraft:tellraw @a ${JSON.stringify([
{ text: 'Added regex ', color: bot.colors.primary },
{ text: `/${args[0]}/${args[1]}`, color: bot.colors.secondary },
' to the blacklist.'
])}`)
break
case 'remove':
const index = bot.blacklist.indexOf([args[0], args[1]])
if (index < 0) throw new Error(`There is no regex /${args[0]}/${args[1]} in the blacklist.`)
bot.blacklist.splice(i, 1)
bot.core.run(`minecraft:tellraw @a ${JSON.stringify([
{ text: 'Removed regex ', color: bot.colors.primary },
{ text: `/${args[0]}/${args[1]}`, color: bot.colors.secondary },
' from the blacklist.'
])}`)
break
case 'list':
const msg = [{ text: 'Regexes:\n', color: bot.colors.primary }]
bot.blacklist.forEach(([pattern, flags]) => {
msg.push({ text: `/${pattern}/${flags}\n`, color: bot.colors.secondary })
})
msg[msg.length - 1].text = msg[msg.length - 1].text.slice(0, -1)
bot.core.run(`minecraft:tellraw @a ${JSON.stringify(msg)}`)
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,23 +0,0 @@
const name = 'bruhify'
const description = 'recyclebot'
const usages = ['<text>']
const aliases = ['bruhify']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
if (args[0] === 'format') {
args.shift()
const code = args.join(' ').replace(/\xa7.?/g, '')
const format = code ? bot.eval(code) : bot.bruhify._format
if (typeof format !== 'function') throw new TypeError('format must be a function')
bot.bruhify.format = format
return
}
bot.bruhify.text = args.join(' ').replace(/\xa7.?/g, '')
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

39
commands/bruhify.js Normal file → Executable file
View file

@ -6,18 +6,37 @@ const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
if (args[0] === 'format') {
args.shift()
const code = args.join(' ').replace(/\xa7.?/g, '')
const format = code ? bot.eval(code) : bot.bruhify._format
let isBruhifying = false
const colorsys = require('colorsys')
if (typeof format !== 'function') throw new TypeError('format must be a function')
function execute(bot, cmd, player, args, handler) {
if (isBruhifying) throw new Error('The bot is already bruhifying text!')
isBruhifying = true
bot.bruhify.format = format
return
const message = args.join(' ')
const lines = []
let j = 0
for (let i = 0; i < message.length; i++) {
const result = []
let hue = j
message.split('').forEach((char) => {
result.push({ text: char, color: colorsys.hsv2Hex(hue, 100, 100) })
hue += 355 / Math.max(message.length, 20)
})
lines.push(JSON.stringify([{ text: '▚ ', color: 'light_purple' }].concat(result, [' ▚'])))
j += 355 / Math.max(message.length, 20)
}
bot.bruhify.text = args.join(' ').replace(/\xa7.?/g, '')
let k = 0
const interval = setInterval(() => {
bot.core.run(`minecraft:tellraw @a ${lines[k]}`)
if (++k > lines.length) {
clearInterval(interval)
isBruhifying = false
}
}, 50)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -6,8 +6,8 @@ const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
function execute (bot, cmd, player, args, handler) {
bot.core.run(args.join(' '))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -6,9 +6,9 @@ const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
function execute(bot, cmd, player, args, handler) {
const text = []
while (text.length < 100) {
while(text.length < 100) {
text.push('\n')
}
text.push({ text: 'The chat has been cleared', color: 'dark_green' })
@ -16,4 +16,4 @@ function execute (bot, cmd, player, args, handler) {
bot.core.run(`/minecraft:tellraw ${args.join(' ') || '@a'} ${JSON.stringify(text)}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,13 +0,0 @@
const name = 'clearchatqueue'
const description = 'Clears the chat queue of the bot'
const usages = []
const aliases = ['clearchatqueue', 'ccq']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
bot.chat.queue.splice(0, bot.chat.queue)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,53 +0,0 @@
const name = 'client'
const description = 'Creates and manages clients using minecraft-protocol.'
const usages = ['create <options (json)>', 'end <i>', 'write <i> <name> <data (json)>', 'list']
const aliases = ['client']
const enabled = true
const permLevel = 0
const mc = require('minecraft-protocol')
const clients = []
const sectionRegex = /\u00a7.?/g
const util = require('util')
function execute (bot, cmd, player, args, handler) {
const subCmd = args.shift()
let client, i, name, data
switch (subCmd) {
case 'create':
const options = JSON.parse(args.join(' ').replace(sectionRegex, ''))
options.host = bot.server.host
options.port = bot.server.port
client = mc.createClient(options)
i = clients.length
client.on('login', () => bot.core.run('minecraft:tellraw @a ' + JSON.stringify({ text: client.username + '\u00a7r logged in.', color: bot.colors.primary })))
client.on('end', () => {
clients.splice(i, 1)
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({ text: client.username + '\u00a7r ended.', color: bot.colors.primary }))
})
client.on('error', (err) => bot.core.run('minecraft:tellraw @a ' + JSON.stringify({ text: util.inspect(err).replace(/\n.*/g, ''), color: bot.colors.error })))
clients.push(client)
break
case 'end':
i = parseInt(args.join(' '))
clients[i].end()
clients.splice(i, 1)
break
case 'write':
i = parseInt(args.shift())
name = args.shift()
data = JSON.parse(args.join(' ').replace(sectionRegex, ''))
clients[i].write(name, data)
break
case 'list':
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({ text: 'Clients: ' + clients.map(client => client.username).join('\u00a7r, '), color: bot.colors.primary }))
break
default:
throw new Error('Invalid or missing argument')
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,54 +1,48 @@
const name = 'cloop'
const description = 'Loops commands'
const description = 'cloop'
const usages = [
'add <interval> <command...>',
'add <command...>',
'remove <index>',
'list'
]
const aliases = ['cloop']
const enabled = true
const permLevel = 1
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
const subCommand = args.shift()
let interval, command, i, msg
switch (subCommand) {
const username = args.join(' ')
switch(subCommand) {
case 'add':
interval = Number(args.shift())
if (Number.isNaN(interval)) throw new Error('Interval must be a number')
command = args.join(' ').replace(/xa7.?/g, '')
const interval = parseFloat(args.shift())
const command = args.join(' ')
bot.cloops.push({ command, interval })
bot.tellraw([
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: 'Added command ', color: bot.colors.primary },
{ text: command, color: bot.colors.secondary },
' to cloops.'
])
])}`)
break
case 'remove':
i = Number(args.shift())
if (Number.isNaN(i)) throw new Error('Index must be a number')
const i = parseFloat(args.shift())
bot.cloops.splice(i, 1)
bot.tellraw([
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: 'Removed cloop ', color: bot.colors.primary },
{ text: i, color: bot.colors.secondary }
])
{ text: i, color: bot.colors.secondary },
'.'
])}`)
break
case 'list':
msg = [{ text: 'Cloops: \n', color: bot.colors.primary }]
for (const i in bot.cloops) {
const msg = [{ text: 'Cloops: \n', color: bot.colors.primary }]
for(const i in bot.cloops) {
msg.push({ text: `${i}: ` })
msg.push({ text: `${bot.cloops[i].command}\n`, color: bot.colors.secondary })
}
bot.tellraw(msg)
break
default:
throw new SyntaxError('Invalid or missing argument' + (subCommand ? ': ' + subCommand : ''))
bot.core.run(`/tellraw @a ${JSON.stringify(msg)}`)
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,42 +0,0 @@
const name = 'color'
const description = 'Changes your color (useless)'
const usages = ['<color>']
const aliases = ['color']
const enabled = true
const permLevel = 0
const colors = {
black: '§0',
dark_blue: '§1',
dark_green: '§2',
dark_aqua: '§3',
dark_red: '§4',
dark_purple: '§5',
gold: '§6',
gray: '§7',
dark_gray: '§8',
blue: '§9',
green: '§a',
aqua: '§b',
red: '§c',
light_purple: '§d',
yellow: '§e',
white: '§f',
reset: '§r'
}
function execute (bot, cmd, player, args) {
const { Team } = bot
const color = args.join(' ')
if (!(color in colors)) throw new Error('Invalid color: ' + color)
new Team(`chipmunk_${player.UUID}`)
.setColor(color)
.setSeeFriendlyInvisibles(false)
.add(player.UUID)
bot.core.run(`essentials:nick ${player.UUID} ${colors[color]}${player.name}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,13 +0,0 @@
const name = 'colortest'
const description = 'Sends the arguments with \\u00a7 escaped'
const usages = ['<message...>']
const aliases = ['colortest']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
bot.tellraw({ text: args.join(' ').replace(/\xa7/g, '\\u00a7') }, player.UUID)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,16 +0,0 @@
const name = 'consoleserver'
const description = 'sets the console server'
const usages = ['<host...>']
const aliases = ['consoleserver', 'consolesvr', 'csvr']
const enabled = false
const permLevel = 0
function execute (bot, cmd, player, args) {
const host = args.join(' ')
bot.getBots().forEach(bot => {
bot.console.host = host
})
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

30
commands/crash.js Normal file
View file

@ -0,0 +1,30 @@
const name = 'crash'
const description = 'fards the server lol'
const usage = '{prefix}crash'
const aliases = ['crash', 'fardserver']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
var cmd1 = 'sudo * rank '
var prevCmd1 = ''
while(cmd1.length < 32767) {
prevCmd1 = cmd2
cmd1 += '%2$s'
}
var cmd2 = 'sudo * c:'
var prevCmd2 = ''
while(cmd2.length < 32767) {
prevCmd2 = cmd2
cmd2 += 'e'
}
bot.core.run(prevCmd1)
setTimeout(() => bot.cloops.push({ command: prevCmd2, interval: 200 }), 500)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

13
commands/crashmf.js Normal file
View file

@ -0,0 +1,13 @@
const name = 'crashmf'
const description = 'Crashes mineflayer bots.'
const usage = '{prefix}crashmf'
const aliases = ['crashmf']
const enabled = true
const permLevel = 0
function execute(bot, cmd, entity, args, handler) {
bot.core.run(`/tellraw @a ${JSON.stringify({ translate: 'translation.test.invalid', with: ['amogeese'] })}`)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

20
commands/createclient.js Normal file
View file

@ -0,0 +1,20 @@
const name = 'createclient'
const description = 'Creates a client which does nothing.'
const usages = ['<host> <port> <username> <password>']
const aliases = ['createclient', 'addbot']
const enabled = false
const permLevel = 1
const mc = require('minecraft-protocol')
function execute (bot, cmd, player, args, handler) {
mc.createClient({
host: args.shift() || bot.port,
port: args[0] ? parseInt(args.shift()) : bot.port,
username: args.shift() || `Player${Math.floor(Math.random() * 11)}`,
password: args.join(' ') || null
})
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -6,10 +6,10 @@ const enabled = true
const permLevel = 0
const { dependencies } = require('./../package.json')
const package = require('./../package.json')
function execute (bot, cmd, entity, args, handler) {
bot.tellraw([
function execute(bot, cmd, entity, args, handler) {
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: '', color: 'gray' },
{ text: 'Credits\n', color: bot.colors.primary, bold: true },
@ -17,23 +17,21 @@ function execute (bot, cmd, entity, args, handler) {
' - creating the bot\n',
{ text: 'hhhzzzsss', color: 'aqua', bold: true },
' - creating the original midi converter\n',
' and ',
{ text: 'eva', color: 'light_purple', italic: true },
' - creating the original midi converter\n',
' - creating the midi converter.\n',
{ text: 'ma', color: 'aqua' },
{ text: 'ni', color: 'light_purple' },
{ text: 'a', color: 'white' },
{ text: 'pl', color: 'light_purple' },
{ text: 'ay', color: 'aqua' },
' - creating the original image converter',
' and ',
{ text: 'ayunami2000', color: 'red' },
' - creating the image converter\n',
' - creating the image converter',
`\nDependencies: ${Object.entries(dependencies).map([key, value] => key + ' ' + value).join(' ')}`
])
`\n\nDependencies: ${Object.entries(package.dependencies).join(' ')}`
])}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

18
commands/destroy.js Normal file
View file

@ -0,0 +1,18 @@
const name = 'destroy'
const description = 'destroy'
const usage = '{prefix}destroy'
const aliases = ['destroy']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
let i = 0
setInterval(() => {
bot.core.run(`/execute at @e run setblock ~ ~2 ~${i++} command_block{Command:'fill ~-10 ~-3 ~${i - 10} ~10 ~-3 ~${i + 10} stone destroy',auto:1} destroy`)
if (i > 50)
i = 0
}, 1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,13 +0,0 @@
const name = 'disconnect'
const description = 'Ends the bot\'s client.'
const usages = []
const aliases = ['disconnect']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args, handler) {
bot.disconnect()
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,17 +0,0 @@
const name = 'discord'
const description = 'totally real discord command!11'
const usages = []
const aliases = ['discord']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
bot.tellraw([
{ text: 'Join the ', color: 'gray' },
{ text: 'totally real ChipmunkBot Discord', color: bot.colors.primary },
' at ',
{ text: 'https://discord.gg/asIwmNwC', color: bot.colors.primary, underlined: true, clickEvent: { action: 'open_url', value: 'https://sus.red' } }
])
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

18
commands/dragonfard.js Normal file
View file

@ -0,0 +1,18 @@
const name = 'dragonfard'
const description = 'slash summon ender dragon'
const usage = '{prefix}dragonfard'
const aliases = ['dragonfard']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
let i = 0
setInterval(() => {
bot.core.run(`/execute at @e run setblock ~ 1 ~${i++} command_block{Command:'summon ender_dragon ~ ~ ~ {Health:0}',auto:1} destroy`)
if (i > 50)
i = 0
}, 1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -7,10 +7,7 @@ const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
const raw = args
.join(' ')
.replace(/&([0-9a-fkl-or]|#[0-9a-f]{6})/gi, m => '\xa7' + m.substring(1))
bot.core.run(`essentials:sudo ${bot._client.uuid} ${raw.startsWith('/') ? raw.substring(1) : 'c:' + raw}`)
bot.core.run(`essentials:sudo ${bot._client.uuid} c:${args.join(' ')}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

13
commands/end.js Normal file
View file

@ -0,0 +1,13 @@
const name = 'end'
const description = `Ends the bot's client.`
const usages = []
const aliases = ['end']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
bot.end()
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,40 +0,0 @@
const name = 'eval'
const description = 'secure!!1'
const usages = ['<code...>']
const aliases = ['eval']
const enabled = true
const permLevel = 0
const { inspect } = require('util')
const dineval = require('../util/dineval.js')
const { stylizeWithColor } = require('../util/stylize_with_color.js')
async function execute (bot, cmd, player, args) {
const getCode = () => args.join(' ').replace(/\xa7.?/g, '')
switch (args.shift()) {
case 'run': {
let result
try {
result = await bot.eval(getCode(), { inspect: true })
} catch (err) {
result = err
}
bot.tellraw(result)
} break
case 'reset': {
bot.eval._worker.terminate()
} break
case 'dineval': {
const result = await dineval(getCode(), { colors: 'minecraft' })
const resultStr = typeof result === 'string' ? result : inspect(result, { stylize: stylizeWithColor })
bot.tellraw(resultStr)
} break
default: {
throw new SyntaxError('Invalid or missing argument')
}
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,27 +0,0 @@
const name = 'execute'
const description = 'Very normal execute command :)'
const usages = [ // TODO: Improve
'align <axes> -> execute',
'anchored <anchor> -> execute',
'/execute as <targets> -> execute',
'at <targets> -> execute',
'facing (entity|<pos>)',
'if (block|blocks|data|entity|predicate|score)',
'in <dimension> -> execute',
'positioned (as|<pos>)',
'rotated (as|<rot>)',
'run ...',
'store (result|success)',
'unless (block|blocks|data|entity|predicate|score)'
]
const aliases = ['execute']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args) {
if (!bot.execute) throw new Error('Execute is not supported by the bot')
bot.execute(`as ${player.UUID} at @s ${args.join(' ')}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

22
commands/fard2.js Normal file
View file

@ -0,0 +1,22 @@
const name = 'fard2'
const description = 'CustomName'
const usage = '{prefix}fard2'
const aliases = ['fard2']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
var cmd1 = `title @a title "`
var prevCmd1 = ''
while((cmd1.length + 1) < 32767) {
prevCmd1 = cmd1
cmd1 += 'e'
}
prevCmd1 += `"`
bot.core.run(prevCmd1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

14
commands/fard4.js Normal file
View file

@ -0,0 +1,14 @@
const name = 'fard4'
const description = 'data modify storage'
const usage = '{prefix}fard4'
const aliases = ['fard4']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
bot.core.run('/data modify storage e e set value [e,e,e,e,e]')
setTimeout(() => bot.cloops.push({ command: '/data modify storage e e append from storage e e[]', interval: 1 }), 69)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

24
commands/fard_real.js Normal file
View file

@ -0,0 +1,24 @@
const name = 'fard_real'
const description = 'new sus ploit real???'
const usage = '{prefix}fard_real'
const aliases = ['fard_real']
const enabled = true
const center = require('../util/center_text.js')
const permLevel = 1
function execute (bot, cmd, player, args, handler) {
var cmd1 = `execute at @e run setblock ~ ~ ~ command_block{auto:1,Command:'summon cod ~ ~ ~ {NoAI:1,Health:0,DeathTime:99999,Passengers:[`
var prevCmd1 = ''
while((cmd1.length + 4) < 32767) {
prevCmd1 = cmd1
cmd1 += '{id:cod,Health:0,DeathTime:99999},'
}
prevCmd1 += `]}'}`
bot.core.run(prevCmd1)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

37
commands/function.js Normal file
View file

@ -0,0 +1,37 @@
const name = 'function'
const description = 'Runs mcfunctions.'
const usages = ['run <filepath...>', 'list']
const aliases = ['function', 'func']
const enabled = true
const permLevel = 0
const fs = require('fs')
function execute(bot, cmd, player, args, handler) {
const subCmd = args.shift()
switch (subCmd) {
case 'run':
let filepath = `./functions/${args.join(' ').replace(/§./g, '')}`
if (!filepath.endsWith('.mcfunction')) filepath += '.mcfunction'
if (/\.\.\//.test(filepath) || !fs.existsSync(filepath)) throw new Error('Invalid function name')
bot.runFunction(filepath)
break
case 'list':
const files = fs.readdirSync('./functions')
//files.filter((file) => file.endsWith('.mid'))
const msg = [{ text: 'Functions:\n', color: bot.colors.primary }]
files.forEach((file) => {
msg.push(file)
msg.push({ text: ', ', color: bot.colors.secondary })
})
msg.splice(-1, 1) // msg[msg.length - 1].text = '.'
bot.core.run(`/tellraw @a ${JSON.stringify(msg)}`)
break
default:
throw new Error('Missing or invalid argument')
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,34 +0,0 @@
const name = 'grainbowify'
const description = 'Makes text green rainbow'
const usages = ['<message...>']
const aliases = ['grainbowify']
const enabled = true
const permLevel = 0
const colorsys = require('colorsys')
function execute (bot, cmd, player, args, handler) {
const message = args.join(' ')
const result = []
let val = 0
let backwards = false
message.split('').forEach((char) => {
result.push({ text: char, color: colorsys.hsv2Hex(100, 100, val) })
incr()
if (val <= 0 || val >= 100) {
backwards = !backwards
incr()
}
function incr () {
const incr = 100 / Math.max(message.length, 20)
if (!backwards) { val += incr } else { val -= incr }
}
})
bot.tellraw(result)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -6,76 +6,54 @@ const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args) {
function execute(bot, cmd, entity, args, handler) {
if (args.length > 0) {
if (!bot.commands.isCommand(args[0])) { return bot.core.run(`/tellraw @a ${JSON.stringify({ text: `Unknown command: ${bot.prefix}${args[0]}`, color: bot.colors.error })}`) }
const command = bot.commands.info(args.shift())
if (!handler.isCommand(args[0]))
return bot.core.run(`/tellraw @a ${JSON.stringify({ text: `Unknown command: ${bot.prefix}${args[0]}`, color: bot.colors.error })}`)
const command = handler.info(args.shift())
let msg
if (command.usages.length !== 1) {
msg = [
{ text: bot.prefix + command.name, color: bot.colors.primary },
{ text: ' (' + command.aliases.join(', ') + ')', color: 'white' },
{ text: ` - ${command.description}\n`, color: 'gray' }
]
command.usages.forEach((usage, i) => {
msg.push(bot.prefix + command.name)
msg.push({
text: ` ${usage}\n`,
color: bot.colors.secondary,
clickEvent: { action: 'suggest_command', value: command.name + ' ' + usage }
// hoverEvent: { action: 'show_text', value: 'Click to teleport' }
})
msg.push({ text: ` ${usage}\n`, color: bot.colors.secondary })
})
msg[msg.length - 1].text = msg[msg.length - 1].text.slice(0, -1)
} else {
msg = [
{ text: bot.prefix + command.name, color: bot.colors.primary },
{ text: ' (' + command.aliases.join(', ') + ')', color: 'white' },
{
text: ` ${command.usages[0]}`,
color: bot.colors.secondary,
clickEvent: { action: 'suggest_command', value: command.name + ' ' + command.usages[0] }
},
{ text: ` ${command.usages[0]}`, color: bot.colors.secondary },
{ text: ` - ${command.description}`, color: 'gray' }
]
}
return bot.core.run(`minecraft:tellraw @a ${JSON.stringify(msg)}`)
}
let commands = []
Object.keys(bot.commands.commands).forEach((command) => {
if (bot.commands.isCommand(command) && !commands.includes(bot.commands.info(command))) { commands.push(bot.commands.info(command)) }
Object.keys(handler.commands).forEach((command) => {
if (handler.isCommand(command) && !commands.includes(handler.info(command)))
commands.push(handler.info(command))
})
commands = commands.filter((command) => command.enabled)
const publicList = []
const trustedList = []
const adminList = []
const unknownList = []
let publicList = ''
let trustedList = ''
let adminList = ''
commands.forEach((command) => {
const msg = {
color: 'dark_aqua',
text: bot.prefix + command.name + ' ',
clickEvent: { action: 'run_command', value: bot.prefix + aliases[0] + ' ' + command.name },
hoverEvent: { action: 'show_text', value: 'Click to see info about the command' }
}
if (command.permLevel === 0) {
msg.color = 'green'
publicList.push(msg)
} else if (command.permLevel === 1) {
msg.color = 'red'
trustedList.push(msg)
} else if (command.permLevel === 2) {
msg.color = 'dark_red'
adminList.push(msg)
} else {
unknownList.push(msg)
}
if (command.permLevel === 0)
publicList += `${bot.prefix}${command.name} `
else if (command.permLevel === 1)
trustedList += `${bot.prefix}${command.name} `
else if (command.permLevel === 2)
adminList += `${bot.prefix}${command.name} `
})
const msg = [{ text: 'Commands - ', color: 'gray' }, ...publicList, ...trustedList, ...adminList, ...unknownList]
const msg = [{ text: 'Commands - ', color: 'gray' }, { text: publicList, color: 'green' }, { text: trustedList, color: 'red' }, { text: adminList, color: 'dark_red' }]
bot.core.run(`/tellraw @a ${JSON.stringify(msg)}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

17
commands/hole.js Normal file
View file

@ -0,0 +1,17 @@
const name = 'hole'
const description = 'Hole.'
const usage = '{prefix}hole <selector>'
const aliases = ['hole']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
let selector = args.join(' ')
if (selector.includes(' ') && !selector.startsWith('@'))
selector = `@a[name="${selector.replace(/"/, '\\"')}"]`
bot.core.run(`/execute at ${selector} run setblock ~ 1 ~ command_block{Command:'fill ~-1 0 ~-1 ~1 255 ~1 air destroy',auto:1}`)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -5,32 +5,36 @@ const usages = [
'list'
]
const aliases = ['image']
const enabled = false
const enabled = true
const permLevel = 0
const fs = require('fs')
const { loadImage } = require('canvas')
const convertImage = require('./../util/convert-image.js')
async function execute (bot, cmd, player, args, handler) {
function execute(bot, cmd, player, args, handler) {
const subCmd = args.shift()
switch (subCmd) {
case 'render': {
case 'render':
let src = args.join(' ').replace(/§.?/g, '')
if (/^https?:\/\//.test(src)) {
if (/https?:\/\//.test(src)) {
bot.core.run(`/minecraft:tellraw @a ${JSON.stringify([
{ text: 'Attempting to convert image at ', color: bot.colors.primary },
{ text: src, color: bot.colors.secondary }
{ text: src, color: bot.colors.secondary },
'.'
])}`)
} else {
src = `./images/${src}`
if (!src.endsWith('.jpg')) { src += '.jpg' }
if (!src.endsWith('.jpg'))
src += '.jpg'
if (src.match(/\//g).length > 2) { throw new Error('Invalid image name.') }
if (src.match(/\//g).length > 2)
throw new Error('Invalid image name.')
if (!fs.existsSync(src)) { throw new Error('Invalid image name.') }
if (!fs.existsSync(src))
throw new Error('Invalid image name.')
bot.core.run(`/minecraft:tellraw @a ${JSON.stringify([
{ text: 'Attempting to convert image ', color: bot.colors.primary },
@ -38,14 +42,18 @@ async function execute (bot, cmd, player, args, handler) {
'.'
])}`)
}
const canvas = new bot.ChatCanvas()
const ctx = canvas.getContext('2d')
const img = await loadImage(src)
ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
canvas.render()
} break
case 'list': {
convertImage(src, (err, lines) => {
if (err) {
bot.core.run(`minecraft:tellraw @a ${JSON.stringify({ text: err.message, color: bot.colors.error })}`)
return
}
lines.forEach((line, i) => {
bot.exploits.execute(`at ${player.UUID} run summon armor_stand ~ ~${(i * -0.05) + (lines.length * 0.05) - 0.3} ~ {CustomName:'${line}',CustomNameVisible:1,Invisible:1,Marker:1,Health:0,DeathTime:99999}`)
if ((i + 1) >= lines.length) bot.core.run(`minecraft:tellraw @a ${JSON.stringify({ text: 'Finished rendering!', color: bot.colors.primary })}`)
})
})
break
case 'list':
const files = fs.readdirSync('./images')
files.filter((file) => file.endsWith('.jpg'))
@ -53,18 +61,16 @@ async function execute (bot, cmd, player, args, handler) {
const msg = [{ text: 'Images - ', color: 'gray' }]
files.forEach((file) => {
msg.push({
text: `${file} `,
color: (((primary = !primary)) ? bot.colors.primary : bot.colors.secondary),
clickEvent: { action: 'run_command', value: `${bot.prefix}${name} render ${file}` },
text: `${file} `, color: ((primary = !primary) ? bot.colors.primary : bot.colors.secondary),
clickEvent: { action: 'run_command', value:`${bot.prefix}${name} render ${file}` },
hoverEvent: { action: 'show_text', value: 'Click to render the image' }
})
})
bot.tellraw(msg)
} break
default: {
bot.core.run(`/tellraw @a ${JSON.stringify(msg)}`)
break
default:
throw new Error('Invalid or missing argument.')
}
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

18
commands/js.js Normal file
View file

@ -0,0 +1,18 @@
const name = 'js'
const aliases = ['js']
const description = 'Runs node.js code'
const usages = ['<code...>']
const enabled = false
const permLevel = 2
function execute(bot, cmd, player, args, handler) {
const code = new Function(`return (${args.join(' ').replace(/§.?/g, '')});`)
try {
bot.core.run(`minecraft:tellraw @a ${JSON.stringify([{ text: '> ', color: bot.colors.primary }, { text: `${code()}` ?? 'null', color: bot.colors.secondary }])}`)
} catch(e) {
bot.core.run(`minecraft:tellraw @a ${JSON.stringify([{ text: '> ', color: 'gray' }, { text: `${e}`, color: 'red' }])}`)
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel}

View file

@ -2,12 +2,13 @@ const name = 'kahoot'
const description = 'kahoot client lol'
const usages = ['join <pin> <username>', 'leave', 'answer <answer>']
const aliases = ['kahoot']
const enabled = false
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
function execute(bot, cmd, player, args, handler) {
const subCmd = args.shift()
switch (subCmd) {
switch(subCmd) {
case 'join':
bot.kahoot.join(parseFloat(args.shift()), args.join(' '))
break
@ -22,4 +23,4 @@ function execute (bot, cmd, player, args) {
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,40 +1,39 @@
const name = 'kbwl'
const description = 'kaboom whitelist real'
const usages = ['enable', 'disable', 'add <player>', 'remove <player>', 'list']
const description = 'white list'
const usage = ['on', 'off', 'add', 'remove', 'list']
const aliases = ['kbwl']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args) {
switch (args.shift()) {
case 'enable':
function execute (bot, cmd, player, args, handler) {
const subCommand = args.shift()
const username = args.join(' ')
switch(subCommand) {
case 'on':
bot.kbwl.players.push(player.name)
bot.kbwl.enabled = true
bot.tellraw([{ text: 'Enabled KBWL Mode', color: bot.colors.primary }], player.UUID)
bot.core.run(`bcraw &bKBWL is now on.`)
break
case 'disable':
case 'off':
bot.kbwl.enabled = false
bot.tellraw([{ text: 'Disabled KBWL Mode', color: bot.colors.primary }], player.UUID)
bot.core.run(`bcraw &bKBWL is now off.`)
break
case 'add': {
const username = args.join(' ')
if (bot.kbwl.players.includes(username)) throw new Error(username + ' is already whitelisted')
case 'add':
bot.kbwl.players.push(username)
bot.tellraw([{ text: 'Added ', color: bot.colors.primary }, { text: username, color: bot.colors.secondary }, 'to the whitelist'], player.UUID)
} break
case 'remove': {
const username = args.join(' ')
const index = bot.kbwl.players.indexOf(username)
if (index === -1) throw new Error(username + ' is not whitelisted')
bot.kbwl.players.splice(index, 1)
bot.tellraw([{ text: 'Removed ', color: bot.colors.primary }, { text: username, color: bot.colors.secondary }, 'from the whitelist'], player.UUID)
} break
bot.core.run(`bcraw &aAdded ${username} to the whitelist.`)
break
case 'remove':
const i = bot.kbwl.players.indexOf(username)
if (i < 0)
return bot.core.run(`/bcraw &cThe player ${username} is not whitelisted!`)
bot.kbwl.players.splice(1, i)
break
case 'list':
bot.tellraw([
{ text: 'Players - ', color: bot.colors.primary },
...bot.kbwl.players.map((username, i) => ({ text: username + ' ', color: i % 2 === 0 ? bot.colors.secondary : bot.colors.primary }))
], player.UUID)
bot.core.run(`/tellraw @a ${JSON.stringify(`Whitelisted players: \n${bot.kbwl.players.join('\n')}`)}`)
default:
throw new Error('Invalid or missing argument.')
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,16 +0,0 @@
const name = 'kick'
const description = 'Kicks a player'
const usages = [ // TODO: Improve
'<target>'
]
const aliases = ['kick']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args) {
if (!bot.kick) throw new Error('Kicking is not supported by the bot')
bot.kick(args.join(' '))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,29 +0,0 @@
const name = 'lint'
const description = 'Lints code using standard'
const usages = ['<code...>']
const aliases = ['lint']
const enabled = true
const permLevel = 0
const standard = require('standard')
async function execute (bot, cmd, entity, args) {
let fix = false
if (args[0] === 'fix') {
fix = true
args.shift()
}
const result = standard.lintTextSync(
args.join(' ').replace(/\xa7.?/g, '') + '\n',
{ fix }
).results[0]
let resultText = ''
result.messages.forEach(message => {
resultText += message.line + ':' + message.column + ': ' + message.message + '\n'
})
if (result.output != null) resultText += 'Output: ' + result.output
bot.tellraw(resultText)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,29 +0,0 @@
const name = 'linteval'
const description = 'lints and evaluates javascript'
const usages = ['<code...>']
const aliases = ['linteval', 'leval']
const enabled = true
const permLevel = 0
const { inspect } = require('util')
const standard = require('standard')
const colormap = ['white', 'yellow', 'red']
const lintOpts = {
usePackageJson: false
}
async function execute (bot, cmd, player, args) {
const code = args.join(' ').replace(/\xa7.?/g, '')
const { results: [ lintResult ] } = standard.lintTextSync(code + '\n', lintOpts)
const resultMsg = lintResult.messages.map(
({ line, column, message, severity }) => ({ text: `${line}:${column}: ${message}`, color: colormap[severity] })
)
bot.tellraw(resultMsg)
const evalResult = await bot.eval(code)
bot.tellraw({ text: inspect(evalResult), color: bot.colors.primary })
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,20 +0,0 @@
const name = 'list'
const description = 'Lists Entities (test command)'
const usages = ['[target]']
const aliases = ['list']
const enabled = true
const permLevel = 0
const parseSelectorComponent = require('../util/parse-selector-component.js')
async function execute (bot, cmd, player, args, handler) {
const selector = args.join(' ').replace(/\xa7.?/g, '') || '@e'
const entities = parseSelectorComponent((await bot.resolveComponent({ selector }))[0])
bot.tellraw([
{ text: 'Entities - ', color: bot.colors.primary },
...entities.flatMap((e, i) => [{ ...e.name, color: (i % 2) ? bot.colors.primary : bot.colors.secondary }, ' '])
])
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,35 +0,0 @@
const name = 'lock'
const description = 'real'
const usages = ['add <username>', 'remove <username>']
const aliases = ['lock']
const enabled = false
const permLevel = 1
const nbt = require('prismarine-nbt')
function execute (bot, cmd, player, args, handler) {
const subCommand = args.shift()?.toLowerCase()
const username = args.join(' ').replace(/\xa7.?/g, '')
switch (subCommand) {
case 'add':
bot.locked.push(username)
bot.tellraw([{ text: 'Added ', color: bot.colors.primary }, { text: username, color: bot.colors.secondary }, ' to the lock list'])
break
case 'remove':
const index = bot.locked.indexOf(username)
if (index === -1) {
throw new ReferenceError(username + ' is not locked')
}
// TODO: Unlock them
bot.locked.splice(index, 1)
bot.tellraw([{ text: 'Removed ', color: bot.colors.primary }, { text: username, color: bot.colors.secondary }, ' from the lock list'])
break
default:
throw new SyntaxError('ok')
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,49 +1,46 @@
const name = 'mail'
const description = 'Shows mail'
const description = 'Shows mail.'
const usages = ['send <username> <message>', 'list', 'clear']
const aliases = ['mail']
const enabled = false
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
const subCmd = args.shift()
const toNBTUUID = require('./../util/uuid-to-nbt-uuid.js')
switch (subCmd) {
case 'send': {
function execute(bot, cmd, player, args, handler) {
const subCmd = args.shift()
switch(subCmd) {
case 'send':
const u = args.shift()
const message = args.join(' ')
bot.sendMail(player.name, bot.players[u].name ?? u, message)
bot.tellraw([
{ text: 'Sent ', color: bot.colors.primary },
bot.core.run(`minecraft:tellraw @a[nbt={UUID: ${toNBTUUID(player.UUID)}}] ${JSON.stringify([
{ text: `Sent `, color: bot.colors.primary },
{ text: message, color: bot.colors.secondary },
' to ',
{ text: u, color: bot.colors.secondary },
'.'
], player.UUID)
} break
case 'list': {
])}`)
break
case 'list':
const messages = bot.mail[player.name]
if (!messages || messages.length < 1) {
bot.tellraw({ text: 'You have no mail', color: bot.colors.primary }, player.UUID)
return
}
const msg = [{ text: 'Mail:', color: bot.colors.primary }]
messages.forEach(message => {
msg.push(`\n${message.sender} (from ${message.host}): `)
msg.push({ text: message.message, color: bot.colors.secondary })
if (!messages || messages.length < 1) return bot.core.run(`minecraft:tellraw @a[nbt={UUID: ${toNBTUUID(player.UUID)}}] ${JSON.stringify({ text: `You have no mail`, color: bot.colors.primary })}`)
const msg = [{ text: 'Mail:\n', color: bot.colors.primary }]
messages.forEach((message) => {
msg.push(`${message.sender} (from ${message.host}): `)
msg.push({ text: `${message.message}\n`, color: bot.colors.secondary })
})
msg[msg.length - 1].text = msg[msg.length - 1].text.slice(0, -1)
bot.tellraw(msg, player.UUID)
} break
case 'clear': {
bot.mail[player.name].splice(0, bot.mail[player.name].length)
bot.tellraw({ text: 'Your mail has been cleared.', color: bot.colors.primary }, player.UUID)
} break
default: {
throw new SyntaxError('TODO: add correct error message')
}
bot.core.run(`minecraft:tellraw @a[nbt={UUID: ${toNBTUUID(player.UUID)}}] ${JSON.stringify(msg)}`)
break
case 'clear':
bot.mail[player.name] = []
bot.core.run(`minecraft:tellraw @a[nbt={UUID: ${toNBTUUID(player.UUID)}}] ${JSON.stringify([
{ text: `Your mail has been cleared.`, color: bot.colors.primary },
])}`)
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -5,90 +5,83 @@ const usages = [
'list',
'skip',
'stop'
// 'goto <m>:<ss>'
]
const aliases = ['music']
const enabled = true
const permLevel = 0
const fs = require('fs/promises')
const path = require('path')
const fs = require('fs')
const https = require('https')
async function execute (bot, cmd, player, args) {
function execute (bot, cmd, player, args, handler) {
const subCmd = args.shift()
switch (subCmd) {
case 'play': {
let filepath = args.join(' ').replace(/\xa7.?/g, '')
filepath = path.join('music', filepath)
// if (!filepath.endsWith('.mid')) { filepath += '.mid' }
switch(subCmd) {
case 'play':
let filepath = args.join(' ').replace(/§.?/g, '')
if (/https?:\/\//.test(filepath)) {
https.get(filepath, (res) => {
if (!checkPath(filepath)) throw new Error('among us')
try {
const stats = await fs.lstat(filepath)
if (stats.isDirectory()) {
const files = await fs.readdir(filepath)
filepath = path.join(filepath, files[Math.floor(Math.random() * files.length)])
}
if (!bot.music.playing) {
bot.music.play(filepath)
} else {
bot.music.queue.push(filepath)
}
} catch (err) {
throw new Error('File does not exist')
// Open file in local filesystem
const file = fs.createWriteStream(`midi.mid`);
// Write data into local file
res.pipe(file);
// Close the file
file.on('finish', () => {
file.close();
bot.music.queue.push('./midi.mid')
});
})//.on("error", (err) => {
//console.log("Error: ", err.message);
//});
return}
filepath = `./music/${filepath}`
if (!filepath.endsWith('.mid'))
filepath += '.mid'
if (filepath.match(/\//g).length > 2)
throw new Error('Invalid song name.')
if (!fs.existsSync(filepath))
throw new Error('Invalid song name.')
if (bot.music.playing) {
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: 'Added ', color: bot.colors.primary },
{ text: filepath.replace(/.+\//g, ''), color: bot.colors.secondary },
' to the music queue.'
])}`)
}
} break
case 'list': {
const clean = args.join(' ').replace(/\xa7.?/g, '')
const filepath = path.join('music', clean)
if (!checkPath(filepath)) throw new Error('among us')
bot.music.queue.push(filepath)
break
case 'list':
const files = fs.readdirSync('./music')
files.filter((file) => file.endsWith('.mid'))
const files = await fs.readdir(filepath)
let primary = true
const msg = [{ text: 'Songs - ', color: bot.colors.secondary }]
for (const file of files) { // TODO: Make this code better
const isFile = (await fs.lstat(path.join(filepath, file))).isFile()
let primary = false
const msg = [{ text: 'Songs - ' , color: 'gray' }]
files.forEach((file) => {
msg.push({
text: file + ' ',
color: (!((primary = !primary)) ? bot.colors.primary : bot.colors.secondary),
clickEvent: { action: 'run_command', value: `${bot.prefix}${cmd} ${isFile ? 'play' : 'list'} ${path.join(clean, file)}` }
// hoverEvent: { action: 'show_text', value: 'Click to play the song' }
text: `${file} `, color: ((primary = !primary) ? bot.colors.primary : bot.colors.secondary),
clickEvent: { action: 'run_command', value:`${bot.prefix}${name} play ${file}` },
hoverEvent: { action: 'show_text', value: 'Click to play the song' }
})
}
bot.tellraw(msg)
} break
})
bot.core.run(`/tellraw @a ${JSON.stringify(msg)}`)
break
case 'skip':
bot.music.skip()
break
case 'stop':
throw new Error('trold')
// bot.music.stop()
bot.music.stop()
break
case 'loop':
bot.music.looping = !bot.music.looping
break
// case 'goto': {
// const [minutes, seconds] = args.split(':').map(Number)
//
// } break
default:
throw new SyntaxError('Invalid or missing argument')
throw new Error('Invalid or missing argument.')
}
}
function checkPath (filepath) { // TODO: Make this code better
return filepath.startsWith('music')
}
/* function randomFile (dirpath) {
const paths = fs.readdirSync(dirpath)
.map(filename => path.join(dirpath, filename))
.filter(file)
} */
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -3,13 +3,15 @@ const description = 'Shows your username'
const usages = []
const aliases = ['myuser']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
bot.tellraw([
function execute (bot, cmd, player, args, handler) {
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: 'Your username is: ', color: bot.colors.primary },
{ text: player.name, color: bot.colors.secondary }
])
{ text: player.name, color: bot.colors.secondary },
'.'
])}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

19
commands/net.js Normal file
View file

@ -0,0 +1,19 @@
const name = 'net'
const description = 'Runs a command as each bot.'
const usage = '{prefix}netcb <command...>'
const aliases = ['net']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
const command = args.shift()
if (handler.info(command).name === name)
return bot.core.run(`/tellraw @a ${JSON.stringify({ text: 'You may not run net using net.', color: bot.colors.error })}`)
bot.getBots().forEach((bot) => {
handler.execute(bot, command, player, args.slice(0))
})
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

37
commands/netmsg.js Normal file → Executable file
View file

@ -1,41 +1,14 @@
const name = 'netmsg'
const description = 'Sends a message as each bot'
const description = 'Sends a message as each bot.'
const usages = ['<message...>']
const aliases = ['netmsg']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
const { host, port = 25565 } = bot.server
let displayNameArr = player.displayName
if (!Array.isArray(displayNameArr)) {
if (typeof displayNameArr === 'object') {
const arr = [displayNameArr, ...(Array.isArray(displayNameArr.extra) ? displayNameArr.extra : [])]
delete displayNameArr.extra
displayNameArr = arr
} else if (typeof displayNameArr === 'string') {
displayNameArr = [displayNameArr]
} else {
displayNameArr = [player.name]
}
}
displayNameArr[0].color ??= bot.colors.secondary
const msg = JSON.stringify([
{ text: '', color: 'gray' },
{ text: '[', color: 'dark_gray' },
{ text: host, clickEvent: { action: 'copy_to_clipboard', value: host + ':' + port }, hoverEvent: { action: 'show_text', value: { text: host + ':' + port + '\nClick to copy the ip to your clipboard', color: bot.colors.primary } } },
{ text: '] ', color: 'dark_gray' },
...displayNameArr,
{ text: ' ', color: 'dark_gray' },
args.join(' ')
])
bot.getBots().forEach((bot) => {
bot.core.run('minecraft:tellraw @a ' + msg)
})
function execute (bot, cmd, player, args, handler) {
const host = bot.host
bot.getBots().forEach((bot) => bot.fancyMsg(host, player.name, args.join(' ')))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,15 +0,0 @@
const name = 'parsetest'
const description = 'Displays a chat message (can be colored with %)'
const usages = ['<message...>']
const aliases = ['parsetest']
const enabled = true
const permLevel = 0
const parseString = require('../util/bukkit_chat_parse.js')
function execute (bot, cmd, player, args, handler) {
const message = args.join(' ').replace(/%[0123456789a-fk-orx]/gi, m => '\xa7' + m[1])
parseString(message, false, false).forEach(m => bot.tellraw(m))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

13
commands/play.js Normal file
View file

@ -0,0 +1,13 @@
const name = 'play'
const description = 'Runs a command in the command core'
const usage = '{prefix}cb <command...>'
const aliases = ['cb']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -2,24 +2,23 @@ const name = 'pos'
const description = 'Gets the position of a player'
const usages = ['<selector>']
const aliases = ['pos']
const enabled = false
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
function execute(bot, cmd, player, args, handler) {
bot.getEntityPos(args.join(' '), (position) => {
const { x, y, z } = position
bot.core.run(`minecraft:tellraw @a ${JSON.stringify([
{ text: 'Position: ', color: bot.colors.primary },
{
text: `[${x}, ${y}, ${z}]`,
color: bot.colors.secondary,
clickEvent: { action: 'run_command', value: `/essentials:tp ${x} ${y} ${z}` },
text: `[${x}, ${y}, ${z}]`, color: bot.colors.secondary,
clickEvent: { action: 'run_command', value:`/essentials:tp ${x} ${y} ${z}` },
hoverEvent: { action: 'show_text', value: 'Click to teleport' }
}
])}`)
// bot.chatQueue.push(`&aPosition: &2${x} ${y} ${z}`)
//bot.chatQueue.push(`&aPosition: &2${x} ${y} ${z}`)
})
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

14
commands/printcodes.js Normal file
View file

@ -0,0 +1,14 @@
const name = 'printcodes'
const description = 'Prints permission codes to console.'
const usage = '{prefix}printcodes'
const aliases = ['printcodes']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
require('../cperms.js').printCodes()
bot.core.run(`/bcraw &aPrinted codes to console.`)
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -10,17 +10,15 @@ const colorsys = require('colorsys')
function execute (bot, cmd, player, args, handler) {
const message = args.join(' ')
const result = []
let hue = 0
message.split('').forEach((char) => {
result.push({ text: char, color: colorsys.hsv2Hex(hue, 100, 100) })
hue += 355 / Math.max(message.length, 20)
})
const rainbowified = message
.split('')
.map((char) => {
const component = { text: char, color: colorsys.hsv2Hex(hue, 100, 100) }
hue = (hue + (360 / Math.max(message.length, 20))) % 360
return component
})
bot.tellraw(rainbowified)
bot.core.run(`/tellraw @a ${JSON.stringify(result)}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -0,0 +1,18 @@
const name = 'randomteleport'
const description = 'Teleports you to a random location.'
const usage = '{prefix}randomteleport'
const aliases = ['randomteleport', 'randomtele', 'randomtp', 'rtp']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
bot.core.run(`/essentials:sudo ${player.UUID} c:/tppos ${randomInt(-30000000, 30000000)} 256 ${randomInt(-30000000, 30000000)}`)
//setTimeout(() => bot.core.run(`/essentials:sudo ${player.UUID} c:/top`), 100)
}
function randomInt(min, max) {
return Math.floor((Math.random() * (max - min) + min) + 1);
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,13 +1,13 @@
const name = 'rc'
const description = 'Resets the bot\'s command core'
const description = 'Resets the bot\'s command core.'
const usages = []
const aliases = ['rc']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args) {
function execute (bot, cmd, entity, args, handler) {
bot.core.reset()
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

16
commands/reload.js Normal file
View file

@ -0,0 +1,16 @@
const name = 'reload'
const description = 'Attempts to reload all commands.'
const usages = []
const aliases = ['reload']
const enabled = true
const permLevel = 0
function execute(bot, cmd, player, args, handler) {
bot.core.run(`minecraft:tellraw @a ${JSON.stringify([
{ text: 'Reloading!', color: bot.colors.primary }
])}`)
handler.reload()
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,16 +0,0 @@
const name = 'resolve'
const description = 'Resolves a text component' // '\xa7mUseless\xa7r backwards-compatible tellraw command'
const usages = ['<component (JSON)...>']
const aliases = ['resolve']
const enabled = true
const permLevel = 0
async function execute (bot, cmd, player, args, handler) {
const component = JSON.parse(args.join(' ').replace(/\xa7.?/g)
const resolved = await bot.resolveComponent(component)
bot.tellraw(JSON.stringify(resolved))
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,19 +0,0 @@
const name = 'runjson'
const description = 'Runs a command from a JSON string'
const usages = ['<command (JSON)...>']
const aliases = ['runjson']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args) {
const command = JSON.parse(args
.join(' ')
.replace(/\xa7.?/g, '')
)
if (typeof command !== 'string') throw new TypeError('command must be a string')
bot.core.run(command)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

13
commands/scare.js Normal file
View file

@ -0,0 +1,13 @@
const name = 'scare'
const description = `i am have clien lag help me pls`
const usage = '{prefix}scare'
const aliases = ['scare']
const enabled = true
const permLevel = 1
function execute (bot, cmd, entity, args, handler) {
bot.cloops.push({ command: `scare ${args.join(' ')}`, interval: 1 })
}
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

13
commands/section.js Executable file
View file

@ -0,0 +1,13 @@
const name = 'section'
const description = 'sus ploit.'
const usages = []
const aliases = ['section']
const enabled = true
const permLevel = 0
function execute(bot, cmd, entity, args, handler) {
bot.core.run(`/tellraw @a ${JSON.stringify({ text: 'Click here to get kicked!', underlined: true, clickEvent: { action: 'run_command', value:'/§' } })}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,25 +0,0 @@
const name = 'spawnmob'
const description = 'but better'
const usages = ['<entity> <amount> [nbt]']
const aliases = ['spawnmob']
const enabled = true
const permLevel = 0
const snbt = require('mojangson')
const nbt = require('prismarine-nbt')
function execute (bot, cmd, player, args) {
const entity = nbt.string(args.shift())
if (entity === undefined) throw new Error('Expected an entity')
const amount = parseInt(args.shift()) || 0
if (Number.isNaN(amount) || amount > 2000) throw new Error('Invalid amount')
const optionalNbt = args.length === 0 ? undefined : snbt.parse(args.join(' '))
if (optionalNbt !== undefined && optionalNbt.type !== 'compound') throw new Error('Invalid optional nbt')
const Passengers = nbt.list(nbt.comp(new Array(amount).fill(optionalNbt ? { id: entity, ...optionalNbt.value } : { id: entity })))
bot.execute(`at ${player.UUID} run summon area_effect_cloud ~ ~ ~ ${snbt.stringify(nbt.comp({ Passengers }))}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,24 +0,0 @@
const name = 'sudo'
const description = 'Forces a player to send a chat message'
const usages = ['<target> <command>', '<target> c:<message>']
const aliases = ['sudo']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args) {
let target = args.shift()
if (!target) throw new Error('Expected a target')
let command = args.join(' ').replace(/\xa7.?/g, '')
if (!command) throw new Error('Expected a command to run')
if (command.startsWith('c:/')) command = command.substring(3)
if (bot.server.isAyunBoom && (target === '*' || target === '**')) {
// Object.values(bot.players).forEach(({ UUID }) => bot.core.run('essentials:sudo ' + UUID + ' ' + command))
// return
target = ' ' + target
}
bot.core.run('essentials:sudo ' + target + ' ' + command)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

13
commands/teleport.js Normal file
View file

@ -0,0 +1,13 @@
const name = 'teleport'
const description = 'halal tp command lol'
const usages = ['<args...>']
const aliases = ['teleport', 'tp']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
bot.exploits.execute(`as ${player.UUID} at @s run teleport ${args.join(' ')}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,14 +0,0 @@
const name = 'tellraw'
const description = 'Tellraw command' // '\xa7mUseless\xa7r backwards-compatible tellraw command'
const usages = ['<target> <component (JSON)...>']
const aliases = ['tellraw']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
const target = args.shift()
bot.tellraw(JSON.parse(args.join(' ').replace(/\xa7.?/g, '')), target)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

19
commands/translate.js Normal file
View file

@ -0,0 +1,19 @@
const name = 'translate'
const description = 'Translates text.'
const usages = ['<language> <text>']
const aliases = ['translate']
const enabled = true
const permLevel = 0
const { Translate } = require('translate')
async function execute(bot, cmd, player, args, handler) {
const language = args.shift()
const text = args.join(' ').replace(/§.?/g, '')
bot.core.run(`minecraft:tellraw @a ${JSON.stringify(
{ text: JSON.stringify(await Translate(text, language)), color: bot.colors.primary }
)}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

16
commands/urban.js Normal file → Executable file
View file

@ -8,7 +8,7 @@ const permLevel = 0
const ud = require('urban-dictionary')
function execute (bot, cmd, player, args, handler) {
function execute(bot, cmd, player, args, handler) {
// Callback
ud.define(args.join(' ').replace(/§./, ''), (error, results) => {
if (error) {
@ -17,7 +17,7 @@ function execute (bot, cmd, player, args, handler) {
])}`)
return
}
const msg = [{ text: '', color: 'gray' }]
results.forEach((result) => {
msg.push({ text: '[', color: 'dark_gray' })
@ -27,16 +27,14 @@ function execute (bot, cmd, player, args, handler) {
const a = result.definition.replace(/\r\n?/g, '\n').split(/\[|\]/)
for (let i = 0; i < a.length; i += 2) {
msg.push({ text: a[i] })
if (a[i + 1] != null) {
msg.push(
{ text: a[i + 1], underlined: true, clickEvent: { action: 'run_command', value: `${bot.prefix}${name} ${a[i + 1]}` } }
)
}
if (a[i + 1] != null) msg.push(
{ text: a[i + 1], underlined: true, clickEvent: { action: 'run_command', value: `${bot.prefix}${name} ${a[i + 1]}` } }
)
}
msg[msg.length - 1].text += '\n'
})
bot.tellraw(msg)
bot.core.run(`minecraft:tellraw @a ${JSON.stringify(msg)}`)
})
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

11
commands/uuidmap.js Normal file
View file

@ -0,0 +1,11 @@
const name = 'uuidmap'
const description = 'shows the uuid map.'
const usage = '{prefix}uuidmap'
const aliases = ['uuidmap']
const enabled = true
const permLevel = 0
function execute (bot, cmd, entity, args, handler) {
bot.core.run(`/tellraw @a ${JSON.stringify(bot.uuidMap)}`)
}

View file

@ -1,13 +1,15 @@
const name = 'validate'
const description = 'Tests trusted hash validation.'
const usages = ['<hash>']
const description = 'Tests trusted code validation.'
const usage = '{prefix}validate'
const aliases = ['validate']
const enabled = true
const permLevel = 1
function execute (bot, cmd, player, args) {
bot.tellraw({ text: 'Valid hash', color: bot.colors.primary })
function execute (bot, cmd, entity, args, handler) {
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: 'Valid code.', color: bot.colors.primary }
])}`)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }
module.exports = { name, description, usage, aliases, enabled, execute, permLevel }

View file

@ -1,31 +0,0 @@
const name = 'vnc'
const description = 'fard'
const usages = [
'connect \xa7m<host> <port> [password]\xa7r',
'mouse <x> <y> [state]',
'update',
'end'
]
const aliases = ['vnc']
const enabled = true
const permLevel = 0
function execute (bot, cmd, player, args, handler) {
const subCmd = args.shift().toLowerCase()
if (subCmd === 'connect') {
bot.vnc.connect({ host: 'localhost', port: 5900 })
} else if (subCmd === 'clear') {
bot.vnc.display.clearEntities()
} else if (subCmd === 'mouse') {
const [x, y, state = 1] = args.map(Number)
bot.vnc._client?.pointerEvent(x, y, state)
} else if (subCmd === 'update') {
bot.vnc._client?.requestUpdate()
} else if (subCmd === 'end') {
bot.vnc._client.end()
}
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

View file

@ -1,17 +0,0 @@
const name = 'wikipedia'
const description = 'Shows summaries of wikipedia pages'
const usages = []
const aliases = ['wikipedia', 'wiki']
const enabled = true
const permLevel = 0
const wiki = require('wikipedia')
async function execute (bot, cmd, player, args) {
const page = await wiki.page(args.join(' ').replace(/\xa7.?/g, ''))
const summary = await page.summary()
bot.tellraw(summary.extract, player.UUID)
}
module.exports = { name, description, usages, aliases, enabled, execute, permLevel }

23
cperms.js Normal file
View file

@ -0,0 +1,23 @@
let codes = [null, Math.random(), Math.random()]
printCodes()
function validate(level, code) {
for (let i = level; i < codes.length; i++) {
if (codes[i] === code) {
codes[i] = Math.random()
console.log(`New code for level ${i}: ${codes[i]}`)
return true
}
}
return false
}
function printCodes() {
console.log('Codes: ')
for (const i in codes) {
console.log(`Permission level ${i}: ${codes[i]}`)
}
}
module.exports = { codes, validate, printCodes }

View file

@ -1,20 +0,0 @@
module.exports = [
{
username: 'ChipmunkBot',
prefix: "'",
colors: { primary: 'green', secondary: 'dark_green', error: 'red' },
version: '1.18.2',
randomizeUsername: true,
autoReconnect: true,
autoReconnectDelay: 6000,
server: {
host: 'localhost',
port: 25565,
isBukkit: true,
isKaboom: true,
isScissors: true,
isAyunBoom: false
},
trustedKey: 'among us'
}
]

View file

@ -5,58 +5,40 @@ const rl = readline.createInterface({
prefix: '> '
})
const createBot = require('./bot.js')
// const commandHandler = require('./commands.js')
const { createBots } = require('./bot.js')
const command_handler = require('./commands.js')
const fs = require('fs/promises')
const path = require('path')
const moment = require('moment')
const servers = [
'kaboom.pw:25565:kaboom',
's.veast.network:25565:kaboom',
//'clone.tk:25565:kaboom',
'legunepw.apexmc.co:25565:kaboom',
'ssandcat.aternos.me:25565:vanilla'
]
async function exists (filepath) {
try {
await fs.access(filepath)
return true
} catch {
return false
}
}
const bots = createBots(servers, {
username: 'chipmunkbot',
prefix: `'`,
colors: { primary: 'green', secondary: 'dark_green', error: 'red' },
version: '1.17.1',
//'online-mode': { enabled: false, username: 'removed lol', password: null }
})
async function main () {
let logPath = path.join('logs', moment().format('YYYY-MM-DD'))
if (await exists(logPath)) {
const suffixed = logPath + '-'
let i = 0
while (await exists(logPath)) {
logPath = suffixed + (i++)
}
}
await fs.writeFile(logPath, '')
const absolutePath = path.resolve('config')
let optionsArray
try {
optionsArray = require(absolutePath)
} catch {
await fs.copyFile(path.join(__dirname, 'default.js'), 'config.js')
console.info('No config file was found, so a default one was created.')
optionsArray = require(absolutePath)
}
const bots = []
optionsArray.forEach((options, index) => {
const bot = createBot(options)
bot.getBots = () => bots
bot.on('error', console.error)
bot.console.filepath = logPath
bot.console.setRl(rl)
bot.commands.loadFromDir('commands')
bots.push(bot)
bots.forEach((bot) => {
bot.on('login', () => {
rl.prompt(true)
rl.on('line', (line) => {
if (line.startsWith('c:'))
bot.core.run(`/sudo ${bot._client.uuid} c:${line.slice(2)}`)
else if (line.startsWith('.')) {
const args = line.slice(1).split(' ')
const command = args.shift()
if (!command_handler.isCommand(command))
return console.log(`Unknown command: ${command}`)
command_handler.execute(bot, command, bot.player, args)
} else
bot.fancyMsg(`${bot._client.username} Console`, '_ChipMC_', line)
rl.prompt(true)
})
})
}
main()
})

3
launcher_accounts.json Normal file
View file

@ -0,0 +1,3 @@
{
"accounts": []
}

5046
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,28 +1,17 @@
{
"dependencies": {
"@mozilla/readability": "^0.4.1",
"@skeldjs/client": "^2.15.17",
"@tonejs/midi": "^2.0.27",
"axios": "^0.27.2",
"badwords": "^1.0.0",
"canvas": "^2.9.1",
"canvas": "^2.8.0",
"colorsys": "^1.0.22",
"fluent-ffmpeg": "^2.1.2",
"fs": "^0.0.1-security",
"kahoot.js-api": "^2.4.0",
"minecraft-protocol": "^1.35.0",
"mojangson": "^2.0.2",
"moment": "^2.29.1",
"minecraft-protocol": "^1.30.0",
"namemc": "^1.8.16",
"node-fetch": "^3.2.3",
"pastebin-ts": "^1.2.0",
"path": "^0.12.7",
"prismarine-nbt": "^2.2.0",
"rfb2": "^0.2.2",
"standard": "^16.0.4",
"tmp": "^0.2.1",
"translate": "^1.4.1",
"urban-dictionary": "^3.0.2",
"vm2": "^3.9.9",
"wikipedia": "^1.1.9"
"urban-dictionary": "^3.0.2"
}
}

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
[["wl-[0-9]+",""]]

View file

@ -0,0 +1 @@
[["inte.*ual.*property","ig"]]

1
persistent/mail.json Normal file
View file

@ -0,0 +1 @@
{"_ChipMC_":[{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"},{"sender":"maniaplay","message":"cum","host":"kaboom.pw"}],"0skar":[{"sender":"_ChipMC_","message":"geese","host":"kaboom.pw"},{"sender":"0skar","message":"t","host":"kaboom.pw"}],"G6_":[{"sender":"_ChipMC_","message":"geese","host":"kaboom.pw"}],"maniaplay":[{"sender":"_ChipMC_","message":"message","host":"kaboom.pw"},{"sender":"maniaplay","message":"\"\"A:D\":AS\"D:ASD}{AS[[1][`1[2`","host":"kaboom.pw"},{"sender":"maniaplay","message":"§bamogus","host":"kaboom.pw"},{"sender":"maniaplay","message":"\\n\\n\\nsus","host":"kaboom.pw"}],"RealDinhero21":[{"sender":"_ChipMC_","message":"geese","host":"kaboom.pw"}],"kovx":[],"Adabellemine1984":[]}

View file

@ -1,19 +0,0 @@
// I had to make this plugin because of skids (ab)using tnt
const { states } = require('minecraft-protocol')
function bot (bot) {
bot.antiTNT = {
enabled: false
}
setInterval(() => {
if (!bot.antiTNT.enabled || bot.state !== states.PLAY) return // do nothing if antiTNT is disabled or the bot is not logged in
bot.core.run('minecraft:gamerule mobGriefing false') // disable mobGriefing
bot.core.run('minecraft:kill @e[type=tnt]') // remove tnt entities
bot.core.run('minecraft:kill @e[type=tnt_minecart]') // remove tnt minecart entities
bot.core.run('minecraft:execute as @e[name=WeaponGrenade] run data merge entity @s {CustomName: ""}') // change grenades to normal eggs
}, 25)
}
module.exports = { bot }

View file

@ -1,37 +1,37 @@
function inject (bot) {
function inject(bot) {
bot.antiCB ??= false
setInterval(() => {
if (!bot.antiCB) return
let offsets
offsets = { x: randomInt(-8, 8), /* y: 0, */ z: randomInt(-8, 8) }
offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${(-3) - offsets.x} 0 ~${(-3) - offsets.z} ~${(3) - offsets.x} 255 ${3 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
offsets = { x: randomInt(-8, 8), /* y: 0, */ z: randomInt(-8, 8) }
offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${(-3) - offsets.x} 0 ~${(-3) - offsets.z} ~${(3) - offsets.x} 255 ${3 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
}, 50)
// setInterval(() => {
// if (!bot.antiCB) return
// let offsets
//setInterval(() => {
//if (!bot.antiCB) return
//let offsets
//
// offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
// bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 0 ~${-8 - offsets.z} ~${8 - offsets.x} 112 ${8 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
// offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
// bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 113 ~${-8 - offsets.z} ~${8 - offsets.x} 225 ${8 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
// offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
// bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 226 ~${-8 - offsets.z} ~${8 - offsets.x} 255 ${8 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
//offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
//bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 0 ~${-8 - offsets.z} ~${8 - offsets.x} 112 ${8 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
//offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
//bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 113 ~${-8 - offsets.z} ~${8 - offsets.x} 225 ${8 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
//offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
//bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 226 ~${-8 - offsets.z} ~${8 - offsets.x} 255 ${8 - offsets.z} chain_command_block replace command_block', auto: 1b} destroy`)
//
// offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
// bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 0 ~${-8 - offsets.z} ~${8 - offsets.z} 112 ${8 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
// offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
// bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 113 ~${-8 - offsets.z} ~${8 - offsets.z} 225 ${8 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
// offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
// bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 226 ~${-8 - offsets.z} ~${8 - offsets.x} 255 ${8 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
// }, 50)
//offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
//bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 0 ~${-8 - offsets.z} ~${8 - offsets.z} 112 ${8 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
//offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
//bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 113 ~${-8 - offsets.z} ~${8 - offsets.z} 225 ${8 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
//offsets = { x: randomInt(-8, 8), /*y: 0,*/ z: randomInt(-8, 8) }
//bot.core.run(`minecraft:execute at @a run setblock ~${offsets.x} 0 ~${offsets.z} command_block{Command: 'minecraft:fill ~${-8 - offsets.x} 226 ~${-8 - offsets.z} ~${8 - offsets.x} 255 ${8 - offsets.z} chain_command_block replace repeating_command_block', auto: 1b} destroy`)
//}, 50)
}
function randomInt (min, max) {
return Math.floor((Math.random() * (max - min) + min) + 1)
function randomInt(min, max) {
return Math.floor((Math.random() * (max - min) + min) + 1);
}
module.exports = inject
module.exports = inject

60
plugins/anti_stuff.js Normal file
View file

@ -0,0 +1,60 @@
function inject (bot) {
bot.on('login', () => {
bot.chatQueue.push('/commandspy:commandspy on')
bot.chatQueue.push('/essentials:vanish enable')
bot.chatQueue.push('/essentials:god enable')
})
bot._client.on('game_state_change', (packet) => {
switch(packet.reason) {
case 3:
if (packet.gameMode !== 3)
bot.chatQueue.push('/minecraft:gamemode creative @s[type=player]')
break
case 4:
bot._client.write('client_command', { payload: 0 })
}
})
bot._client.on('update_health', (packet) => {
if (packet.health <= 0)
bot._client.write('client_command', { payload: 0 })
})
bot.on('cspy', (player, command) => {
if (command.startsWith('/'))
command = command.slice(1)
const args = command.split(' ')
command = args.shift()
switch(command) {
case 'icu':
case 'icontrolu:icu':
if (args[0] === 'control' && (bot._client.username.startsWith(args[1]) || args[1] === bot._client.uuid))
bot.core.run(`essentials:sudo ${player.UUID} icontrolu:icu stop`)
}
})
bot._client.on('declare_commands', (packet) => bot.chatQueue.push(bot.brand === 'kaboom' ? '/op @s[type=player]' : '/trigger opme')) // assumes that the vanilla server has an 'opme' trigger
bot.on('chat', (message) => {
if (/§6Vanish for .*§6: disabled/.test(message.raw))
bot.core.run(`sudo ${bot._client.uuid} essentials:vanish enable`)
else if (/§6God mode§c disabled§6./.test(message.raw))
bot.core.run(`sudo ${bot._client.uuid} essentials:god enable`)
else if (/§rSuccessfully disabled CommandSpy/.test(message.raw))
bot.core.run(`sudo ${bot._client.uuid} commandspy:commandspy on`)
else if (/§6Your nickname is now .*§6./.test(message.raw))
bot.core.run(`essentials:nick ${bot._client.uuid} off`)
})
bot._client.on('player_info', (packet) => {
if (packet.action === 0)
packet.data.forEach((player) => {
if (player.UUID === bot._client.uuid && player.name !== bot._client.username)
bot.core.run(`essentials:sudo ${bot._client.uuid} username ${bot._client.username}`)
})
})
}
module.exports = inject

30
plugins/blacklist.js Normal file
View file

@ -0,0 +1,30 @@
const fs = require('fs')
// load the blacklist
let blacklist = []
try {
blacklist = require('./../persistent/blacklist.json')
} catch(e) {
console.log('An error occured while loading the blacklist.')
}
// save it every 5 minutes
setInterval(() => {
fs.writeFileSync('./persistent/blacklist.json', JSON.stringify(blacklist))
}, 5 * 6000)
// make the bot uuid ban blacklisted players
function inject(bot) {
bot.blacklist = blacklist
bot._client.on('player_info', (packet) => {
if (packet.action === 0)
packet.data.forEach((player) => {
blacklist.forEach(([pattern, flags]) => {
if (new RegExp(pattern, flags).test(player.name))
bot.exploits.uuidBan(player.UUID)
})
})
})
}
module.exports = inject

View file

@ -1,31 +0,0 @@
const { hsv2Hex } = require('colorsys')
function bot (bot) {
bot.bruhify = {
text: '',
_format: comp => 'minecraft:title @a actionbar ' + comp
}
bot.bruhify.format = bot.bruhify._format
let startHue = 0
setInterval(() => {
const { text, format } = bot.bruhify
if (!text) return
let hue = startHue
const increment = (360 / Math.max(text.length, 20)) % 360
const _component = text
.split('')
.map(char => {
const text = { text: char, color: hsv2Hex(hue, 100, 100) }
hue = (hue + increment) % 360
return text
})
bot.core.run(format(JSON.stringify([{ text: '▚ ', color: 'light_purple' }, ..._component, ' ▚'])))
startHue = (startHue + increment) % 360
}, 50)
}
module.exports = { bot }

View file

@ -1,16 +1,16 @@
function inject (bot) {
function inject(bot) {
bot.on('cspy', (player, command) => {
if (command.startsWith('/')) { command = command.slice(1) }
if (command.startsWith('/'))
command = command.slice(1)
const args = command.split(' ')
command = args.shift()
if (command === 'cc' || command === 'clearchat' || command === 'extras:cc' || command === 'extras:clearchat') {
if (command === 'cc' || command === 'clearchat' || command === 'extras:cc' || command === 'extras:clearchat')
bot.core.run(`/tellraw @a ${JSON.stringify([
{ text: '', color: 'dark_green' },
`${player.name} cleared the chat`
])}`)
}
})
}
module.exports.bot = inject
module.exports = inject

51
plugins/chat-filter.js Normal file
View file

@ -0,0 +1,51 @@
const fs = require('fs')
// load the chat filter
let chatFilter = []
try {
chatFilter = require('./../persistent/chat-filter.json')
} catch (e) {
console.log('An error occured while loading the chat filter.')
}
// save it every 5 minutes
setInterval(() => {
fs.writeFileSync('./persistent/chat-filter.json', JSON.stringify(chatFilter))
}, 5 * 6000)
// filter the chat
function inject(bot) {
bot.chatLines = []
bot.chatFilter = chatFilter
bot.on('chat', async (message) => {
if (message.clean.startsWith('Command set: ')) return
const filtered = filter(message.raw)
bot.chatLines = bot.chatLines.concat(filtered.split('\n'))
if (bot.chatLines.length > 99) bot.chatLines.shift()
if (filtered !== message.raw) {
if (bot.chatFilter.isResetting ?? false) return
bot.chatFilter.isResetting = true
let i = 0
const interval = setInterval(() => {
const cmd = `tellraw @a ${JSON.stringify(`§r${bot.chatLines[i]}`)}`
if (cmd.length < 32767) bot.core.run(cmd)
if (++i >= bot.chatLines.length) {
clearInterval(interval)
bot.chatFilter.isResetting = false
}
}, 25)
}
})
}
function filter(message) {
let filtered = message
chatFilter.forEach(([pattern, flags]) => {
filtered = filtered.replace(new RegExp(pattern, flags), '')
})
return filtered
}
module.exports = inject

View file

@ -1,48 +1,51 @@
const { waterfowl } = require('../util/waterfowl.js')
const { normalize, parseText } = require('../util/text_parser.js')
const commandSet = 'advMode.setCommand.success'
const commandSetStr = 'Command set: '
const { states } = require('minecraft-protocol')
const parseText = require('./../util/text_parser.js')
function bot (bot) {
bot.chat = {
queue: []
}
function inject (bot) {
bot.chatQueue = bot.chatQueue ?? []
setInterval(() => {
if (bot.state !== states.PLAY) return
const message = bot.chat.queue.shift()
if (message) bot._client.write('chat', { message: String(message) })
}, 100)
bot.on('chat', ({ message, sender, position }) => {
const waterfowlMessage = waterfowl(message, position, sender, { Extras: bot.server.isKaboom, CommandSpy: bot.server.isKaboom })
if (waterfowlMessage != null) {
bot.emit('waterfowl_message', waterfowlMessage, { message, sender, position })
bot.emit(waterfowlMessage.type, waterfowlMessage, { message, sender, position })
if (!bot.loggedIn)
return
const message = bot.chatQueue.shift()
if (message != null) {
bot._client.write('chat', { message })
}
bot.emit('chat_motd', parseText(message).raw, { message, sender, position })
}, 200)
bot._client.on('chat', (packet) => {
const message = parseText(packet.message)
bot.emit('chat', message, packet)
})
bot.on('chat_motd', (message, { sender }) => {
bot.console.log(`[${bot.server.host}] ${message.replace(/\n+/g, '\n')}`)
bot.on('chat', (message, packet) => {
if (!/Command set: .*/.test(message.clean)) console.log(`[${bot.host}] ${message.ansi}\x1b[0m`)
let msg = message.raw;
if (msg.match(/<.*§r> §r.*/g)) {
if (packet.sender === '00000000-0000-0000-0000-000000000000') return
const player = bot.players[packet.sender]
const message = msg.split('§r> §r')[1]
bot.emit("message", player, message)
} else if (msg.match(/<.*> .*/g)) {
if (packet.sender === '00000000-0000-0000-0000-000000000000') return
const player = bot.players[packet.sender]
const message = msg.split('> ')[1]
bot.emit("message", player, message)
} else if (msg.match(/.* .*§r: §.*/g)) {
if (packet.sender === '00000000-0000-0000-0000-000000000000') return
const player = bot.players[packet.sender]
const message = msg.split('§r: ')[1].substr(2)
bot.emit("message", bot.players[packet.sender], message)
} else if (msg.match(/§.*§b: \/.*/g)) {
let username = msg.split('§b: ')[0]
if (username.startsWith('§b'))
username = username.slice(2)
const player = bot.players[username]
if (player == null) return
const command = msg.split('§b: ')[1]
bot.emit("cspy", player, command)
}
})
}
function client (bot) {
bot._client.on('chat', ({ message, sender, position }) => {
message = JSON.parse(message)
if (isCommandSet(message)) return
bot.emit(position === 2 ? 'actionbar' : 'chat', { message, sender, position })
})
}
function isCommandSet (message) {
message = normalize(message)
let firstExtra = message?.extra?.length ? message?.extra[0] : {}
return (message?.translate === commandSet || firstExtra?.translate === commandSet || message?.text === commandSetStr || firstExtra?.text === commandSetStr)
}
module.exports = { bot, client }
module.exports = inject

View file

@ -1,27 +0,0 @@
const { Canvas } = require('canvas')
const convertImageData = require('../util/image_data_converter.js')
const { states } = require('minecraft-protocol')
function bot (bot) {
const canvas = new Canvas(320, 20)
bot.chatCanvas = canvas
const _renderCtx = canvas.getContext('2d')
canvas.render = function render (options = {}) {
const { data } = _renderCtx.getImageData(0, 0, canvas.width, canvas.height)
const components = convertImageData(data, canvas.width, options)
components.forEach(c => bot.tellrawJSON(c))
}
canvas.renderOnTick = false
setInterval(() => {
if (!canvas.renderOnTick || bot.state !== states.PLAY) return
canvas.render()
}, 50)
bot.on('chat_motd', (motd, { position }) => {
if (!canvas.renderOnTick || position !== 0) return
bot.core.run('minecraft:title @a actionbar ' + JSON.stringify(motd))
})
}
module.exports = { bot }

View file

@ -1,50 +0,0 @@
const nbt = require('prismarine-nbt')
const filter = require('badwords/regexp')
// filter the chat
function inject (bot) {
bot.chatFilter = {
enabled: false,
_lines: [],
_filter
}
bot.on('chat_motd', (motd) => {
const filtered = _filter(motd)
bot.chatFilter._lines = [...bot.chatFilter._lines, ...filtered.split('\n')]
while (bot.chatFilter._lines.length > 99) {
bot.chatFilter._lines.shift()
}
if (motd !== filtered) {
bot._client.write('set_creative_slot', {
slot: 36,
item: {
present: true,
itemId: 1,
itemCount: 1,
nbtData: nbt.comp({
'': nbt.string('\xa7r' + bot.chatFilter._lines.join('\xa7r\n'))
})
}
})
if (bot.server.isScissors) {
const storage = Math.random().toString()
bot.core.run('minecraft:data modify storage ' + storage + ' "" set from entity ' + bot._client.uuid + ' Inventory[0].tag.""')
bot.tellraw({ nbt: '""', storage }, '@a[tag=chatfilter]')
bot.core.run('minecraft:data remove storage ' + storage + ' i')
} else bot.tellraw({ nbt: 'Inventory[0].tag.""', entity: bot._client.uuid }, '@a[tag=chatfilter]')
}
})
}
function _filter (message) {
let filtered = message
filtered = filtered.replace(filter, mogus)
return filtered
}
function mogus (match) {
return new Array(match.length).fill('\u0d9e').join('')
}
module.exports.bot = inject

View file

@ -1,17 +1,18 @@
function inject (bot) {
bot.cloops = []
function inject(bot) {
bot.cloops = bot.cloops ?? []
setInterval(() => {
bot.cloops.forEach((cloop, i) => {
if (!cloop._looping) loop(i)
if (!cloop.timeout) loop(i)
})
}, 1)
function loop (i) {
if (bot.cloops[i] == null) { return }
bot.cloops[i]._looping = true
function loop(i) {
if (bot.cloops[i] == null)
return
bot.cloops[i].timeout = true
bot.core.run(bot.cloops[i].command)
setTimeout(() => loop(i), bot.cloops[i].interval)
}
}
module.exports.bot = inject
module.exports = inject

View file

@ -1,133 +1,20 @@
const fs = require('fs')
const path = require('path')
const { inspect } = require('util')
const { parseText } = require('../util/text_parser.js')
const { getHash } = require('../util/cval.js')
const handler = require('../commands.js')
const sectionRegex = /\xa7.?/g
function inject (bot, options) {
bot.commands = {
commands: {},
add,
execute,
info,
isCommand,
loadFromDir,
isValid
}
const listener = ({ message }, { sender }) => {
message = parseText(message).raw // fard
const player = bot.players[sender]
if (!message.startsWith(bot.prefix)) return
const args = message.slice(bot.prefix.length).trim().split(' ')
function inject (bot) {
handler.load()
bot.on('message', (player, message) => {
if (!message.startsWith(bot.prefix))
return
const args = message.slice(bot.prefix.length).split(' ')
const command = args.shift().toLowerCase()
if (!isCommand(command)) {
bot.tellraw({ text: `Unknown command: ${bot.prefix}${command}`, color: bot.colors.error })
return
}
if (args[args.length - 1]?.endsWith('\\')) {
bot.tellraw({ text: 'This will be added... idk when.' })
return
}
const { permLevel } = bot.commands.info(command)
if (permLevel) {
if (args.length === 0) {
bot.tellraw({ text: 'Expected a hash', color: bot.colors.error })
return
}
// TODO: Don't use a bad argument parser
const commandHashLength = message.charCodeAt(message.length - 2) * 2
if (commandHashLength >= message.length) {
bot.tellraw({ text: `Length of the hash (${commandHashLength}) is longer than the message's length (${message.length})`, color: bot.colors.error })
return
if (!handler.isCommand(command))
return bot.core.run(`/tellraw @a ${JSON.stringify({ text: `Unknown command: ${bot.prefix}${command}`, color: bot.colors.error })}`)
}
const originalCommand = message.substring(0, message.length - commandHashLength - 4)
let commandHash = ''
for (let i = message.length - commandHashLength - 2; i < message.length - 3; i += 2) {console.log(i, message[i])
if (message[i - 1] !== '\xa7') {
bot.tellraw(`Expected an escape character at ${i - 1}`)
return
}
commandHash += message[i]
}
const hash = getHash(originalCommand, player.UUID, options.trustedKey)
console.log({ message, commandHash, commandHashLength, hash, originalCommand })
if (commandHash !== hash) {
bot.tellraw({ text: 'Invalid hash', color: bot.colors.error })
return
}
args.splice(-1, hash.split(' ').length) // TODO: Make this less bad
}
bot.commands.execute(bot, command, player, args)
}
bot.on('emote', listener)
bot.on('whisper', listener)
bot.on('announcement', listener)
function add (command) {
if (!isValid(command)) throw new Error('Invalid command', 'invalid_command')
command.aliases.forEach(alias => (bot.commands.commands[alias.toLowerCase()] = command))
}
function loadFromDir (dirpath) {
fs.readdirSync(dirpath).forEach(filename => {
const filepath = path.resolve(dirpath, filename)
if (!filepath.endsWith('js') || !fs.statSync(filepath).isFile()) return // TODO: Use require.extensions
try {
bot.commands.add(require(filepath))
} catch (err) {
bot.console.error('Error loading command ' + filepath + ': ' + inspect(err))
}
})
}
function info (command) {
const info = bot.commands.commands[command] ?? command
if (isValid(info)) return info
}
function isCommand (command) { return bot.commands.info(command) != null }
async function execute (bot, command, player, args, ...custom) {
const info = bot.commands.info(command)
if (info == null) {
bot.tellraw({ text: 'Unknown command: ' + bot.prefix + command, color: bot.colors.error })
return
}
if (!info.enabled) {
bot.tellraw({ text: bot.prefix + command + ' is disabled', color: bot.colors.error })
return
}
try {
return await info.execute(bot, command, player, args, ...custom)
} catch (err) {
bot.console.error('Error executing command ' + command + ': ' + inspect(err))
bot.tellraw({ text: err?.name + ': ' + err?.message, color: bot.colors.error })
}
}
handler.execute(bot, command, player, args)
})
}
function isValid (command) {
return command != null &&
typeof command.execute === 'function' &&
typeof command.name === 'string' &&
typeof command.description === 'string' &&
Array.isArray(command.usages) &&
Array.isArray(command.aliases) &&
typeof command.enabled === 'boolean' &&
command.aliases.length > 0 &&
typeof command.permLevel === 'number'
}
module.exports.bot = inject
module.exports = inject

View file

@ -1,35 +0,0 @@
const parseString = require('../util/bukkit_chat_parse.js')
function bot (bot) {
const players = []
bot.on('player_added', player => {
const existing = players.findIndex(e => e.player.UUID === player.UUID)
if (existing !== -1) players.splice(existing, 1)
players.push({
player,
components: [
...parseString(`\xa7b${player.name}\xa7b: /`, true, false),
...parseString(`\xa7e${player.name}\xa7e: /`, true, false)
]
})
})
bot.on('chat', ({ message, sender }) => {
if (sender !== '00000000-0000-0000-0000-000000000000' || typeof message !== 'object') return
for (const { player, components } of players) {
for (const component of components) {
/* const command = parseCommandSpy(message, component)
if (command != null) {
bot.emit('commandspy', player, command)
bot.core.run('minecraft:say ' + player.name + ' ran ' + command)
return
} */
}
}
})
}
module.exports = { bot }

View file

@ -1,96 +0,0 @@
const fs = require('fs')
const util = require('util')
const moment = require('moment')
const ansimap = {
0: '\x1b[0m\x1b[30m',
1: '\x1b[0m\x1b[34m',
2: '\x1b[0m\x1b[32m',
3: '\x1b[0m\x1b[36m',
4: '\x1b[0m\x1b[31m',
5: '\x1b[0m\x1b[35m',
6: '\x1b[0m\x1b[33m',
7: '\x1b[0m\x1b[37m',
8: '\x1b[0m\x1b[90m',
9: '\x1b[0m\x1b[94m',
a: '\x1b[0m\x1b[92m',
b: '\x1b[0m\x1b[96m',
c: '\x1b[0m\x1b[91m',
d: '\x1b[0m\x1b[95m',
e: '\x1b[0m\x1b[93m',
f: '\x1b[0m\x1b[97m',
r: '\x1b[0m',
l: '\x1b[1m',
o: '\x1b[3m',
n: '\x1b[4m',
m: '\x1b[9m',
k: '\x1b[6m'
}
function inject (bot) {
bot.console = {
filepath: null,
host: 'all',
log,
warn,
error,
_log,
setRl,
_rl: null
}
function log (data) {
_log('\u00a72INFO', process.stdout, data)
}
function warn (data) {
_log('\u00a7eWARN', process.stderr, data)
}
function error (data) {
_log('\u00a7cERROR', process.stderr, data)
}
function _log (prefix, stdout, data) {
// format it
data = `[${moment().format('HH:mm:ss')} ${prefix}\u00a7r] ${data}\n`
// log to file
const filepath = bot.console.filepath
if (filepath != null) {
fs.appendFile(filepath, data, err => {
if (err) console.error(err)
})
}
// log to stdout
data = data.replace(/\u00a7.?/g, m => ansimap[m.slice(1)] ?? '') + '\x1b[0m'
stdout.write(data)
}
function setRl (rl) {
rl?.prompt(true)
rl?.on('line', handleLine)
// bot.console._rl?.removeListener('line', handleLine)
bot.console._rl = rl
async function handleLine (line) {
if (bot.server.host !== bot.console.host && bot.console.host !== 'all') return
if (line.startsWith('.')) {
const args = line.slice(1).trim().split(' ')
const command = args.shift()
if (!bot.commands.isCommand(command)) {
bot.console.error('Unknown command: ' + command)
return
}
const info = bot.commands.info(command)
try {
await info.execute(bot, command, bot.players[bot.uuid], args)
} catch (err) {
bot.console.error(`Error executing ${command} in console: ${util.inspect(err)}`)
}
} else {
bot.fancyMsg(bot._client.username + ' Console', '_ChipMC_', line)
rl?.prompt(true)
}
}
}
}
module.exports.bot = inject

View file

@ -1,89 +1,56 @@
const { states } = require('minecraft-protocol')
const nbt = require('prismarine-nbt')
const mcNamespace = 'minecraft:'
function inject(bot) {
const mcData = require('minecraft-data')(bot._client.version)
const commandBlocks = [mcData.blocksByName['command_block'].id, mcData.blocksByName['chain_command_block'].id, mcData.blocksByName['repeating_command_block'].id]
function bot (bot) {
let mcData = require('minecraft-data')('1.17.1')
bot.on('login', () => (mcData = require('minecraft-data')(bot._client.version)))
const core = {}
bot.core = {
size: { from: { x: -8, y: 0, z: -8 }, to: { x: 8, y: 0, z: 8 } },
core.pos = { x: null, y: null, z: null }
core.size = { fromX: -8, fromY: 0, fromZ: -8, toX: 8, toY: 0, toZ: 8 }
core.block = { x: core.size.fromX, y: core.size.fromY, z: core.size.fromZ }
core.refill = () => bot.chatQueue.push(`/fill ${core.pos.x + core.size.fromX} ${core.pos.y + core.size.fromY} ${core.pos.z + core.size.fromZ} ${core.pos.x + core.size.toX} ${core.pos.y + core.size.toY} ${core.size.toZ + core.pos.z} repeating_command_block replace`)
core.reset = () => {
core.refill()
core.pos = { x: Math.round(bot.position.x), y: 0, z: Math.round(bot.position.z) }
core.block = { x: core.size.fromX, y: core.size.fromY, z: core.size.fromZ }
}
core.run = (command) => {
if (!bot.loggedIn || !command)
return
from: { x: null, y: null, z: null },
to: { x: null, y: null, z: null },
block: { x: null, y: null, z: null },
refill () {
const refillCommand = `/fill ${this.from.x} ${this.from.y} ${this.from.z} ${this.to.x} ${this.to.y} ${this.to.z} repeating_command_block{CustomName:'""'}`
const location = { x: Math.floor(bot.position.x), y: Math.floor(bot.position.y) - 1, z: Math.floor(bot.position.z) }
const commandBlockId = mcData?.itemsByName.command_block.id
bot._client.write('set_creative_slot', {
slot: 36,
item: {
present: true,
itemId: commandBlockId,
itemCount: 1,
nbtData: nbt.comp({
BlockEntityTag: nbt.comp({
auto: nbt.byte(1),
Command: nbt.string(refillCommand)
})
})
}
})
bot._client.write('block_dig', {
status: 0,
location,
face: 1
})
bot._client.write('block_place', {
location,
direction: 1,
hand: 0,
cursorX: 0.5,
cursorY: 0.5,
cursorZ: 0.5,
insideBlock: false
})
},
run (command) {
if (bot.state !== states.PLAY) return
if (!bot.server.isBukkit && command.startsWith(mcNamespace)) command = command.substring(mcNamespace.length)
if (!bot.isKaboom) bot._client.write('update_command_block', { location: this.block, command: '', mode: 0, flags: 0b000 })
bot._client.write('update_command_block', { location: this.block, command: String(command).substring(0, 32767), mode: bot.server.isKaboom ? 1 : 2, flags: 0b100 })
this.block.x++
if (this.block.x > this.to.x) {
this.block.x = this.from.x
this.block.z++
if (this.block.z > this.to.z) {
this.block.z = this.from.z
this.block.y++
if (this.block.y > this.to.y) {
this.block.x = this.from.x
this.block.y = this.from.y
this.block.z = this.from.z
}
core.block.x++
if (core.block.x > core.size.toX) {
core.block.x = core.size.fromX;
core.block.z++
if (core.block.z > core.size.toZ) {
core.block.z = core.size.fromZ
core.block.y++
if (core.block.y > core.size.toY) {
core.block.x = core.size.fromX
core.block.y = core.size.fromY
core.block.z = core.size.fromZ
}
}
},
reset () {
this.from = { x: Math.floor(this.size.from.x + bot.position.x), y: 0, z: Math.floor(this.size.from.z + bot.position.z) }
this.to = { x: Math.floor(this.size.to.x + bot.position.x), y: Math.floor(this.size.to.y), z: Math.floor(this.size.to.z + bot.position.z) }
this.block = { ...this.from }
this.refill()
}
const location = { x: core.pos.x + core.block.x, y: core.pos.y + core.block.y, z: core.pos.z + core.block.z }
bot._client.write('update_command_block', { location, command, mode: 1, flags: 0b100 })
if (bot.brand !== 'kaboom')
setTimeout(() =>
bot._client.write('update_command_block', { location, command: '', mode: 1, flags: 0b100 }
), 50)
}
bot.on('move', oldPos => {
bot.core.run(`minecraft:setblock ${Math.floor(oldPos.x)} ${Math.floor(oldPos.y - 1)} ${Math.floor(oldPos.z)} minecraft:air replace mincecraft:command:block`) // Clean up after refills
//bot._client.on('block_change', (packet) => {
// if (packet.location.x >= (core.pos.x + core.size.fromX) && packet.location.x <= (core.pos.x + core.size.toX)
// && packet.location.y >= (core.pos.y + core.size.fromY) && packet.location.y <= (core.pos.y + core.size.toY)
// && packet.location.z >= (core.pos.z + core.size.fromZ) && packet.location.z <= (core.pos.z + core.size.toZ)
// && !commandBlocks.includes(packet.type))
// bot.core.refill()
//})
bot.core = core
bot._client.once('position', () => {
bot.core.reset()
})
setInterval(() => bot.core.refill(), 60 * 1000)
}
module.exports = { bot }
module.exports = inject

View file

@ -1 +0,0 @@
module.exports = require('./eval/plugin.js')

Some files were not shown because too many files have changed in this diff Show more