This commit is contained in:
7cc5c4f330d47060 2024-09-19 22:21:01 -04:00
parent 2ca476c0cc
commit 24ce5d13fe
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
16 changed files with 173 additions and 183 deletions

View file

@ -222,8 +222,8 @@ const displayServerList = function (c) {
let message = 'command.about.serverListItem' let message = 'command.about.serverListItem'
if (c.bot.id === i) message = 'command.about.serverListItem.thisServer' if (c.bot.id === i) message = 'command.about.serverListItem.thisServer'
let host = item.host.host let host = item.host.host
let port = item.host.port const port = item.host.port
if(item.host.options && item.host.options.displayAsIPv6){ if (item.host.options && item.host.options.displayAsIPv6) {
host = `[${host}]` host = `[${host}]`
} }
c.reply({ c.reply({

View file

@ -1,5 +1,5 @@
const fs = require('fs') const fs = require('fs')
const settings = require("../settings.json") const settings = require('../settings.json')
const cmds = Object.create(null) const cmds = Object.create(null)
const { getMessage } = require('../util/lang.js') const { getMessage } = require('../util/lang.js')
@ -16,7 +16,7 @@ for (const plugin of bpl) {
} }
try { try {
const commandName = plugin.split('.js')[0] const commandName = plugin.split('.js')[0]
if(commandName == "settings" && settings.userSettingsDisabled) continue if (commandName === 'settings' && settings.userSettingsDisabled) continue
if (commandName !== 'help') { if (commandName !== 'help') {
cmds[commandName] = require(`./${plugin}`) cmds[commandName] = require(`./${plugin}`)
if (cmds[commandName].level === undefined) { if (cmds[commandName].level === undefined) {
@ -32,11 +32,11 @@ const printHelp = (c) => {
const permsT = getMessage(c.lang, 'command.help.permsTrusted') const permsT = getMessage(c.lang, 'command.help.permsTrusted')
const permsO = getMessage(c.lang, 'command.help.permsOwner') const permsO = getMessage(c.lang, 'command.help.permsOwner')
const permList = [permsN, permsT, permsO] const permList = [permsN, permsT, permsO]
const colorList = ["green", "red", "dark_red"] const colorList = ['green', 'red', 'dark_red']
for (const i in cmds) { for (const i in cmds) {
if (cmds[i].hidden) continue if (cmds[i].hidden) continue
let cmdColor let cmdColor
if(colorList[cmds[i].level]){ if (colorList[cmds[i].level]) {
cmdColor = colorList[cmds[i].level] cmdColor = colorList[cmds[i].level]
} else { } else {
cmdColor = colorList[0] cmdColor = colorList[0]
@ -49,7 +49,7 @@ const printHelp = (c) => {
if (cmds[i].desc) { if (cmds[i].desc) {
desc = cmds[i].desc desc = cmds[i].desc
} }
hoverText = [] const hoverText = []
for (const item of usage) { for (const item of usage) {
hoverText.push({ hoverText.push({
translate: getMessage(c.lang, 'command.help.commandUsage.lf'), translate: getMessage(c.lang, 'command.help.commandUsage.lf'),
@ -99,7 +99,7 @@ const printHelp = (c) => {
{ {
text: i, text: i,
hoverEvent: { hoverEvent: {
action: "show_text", action: 'show_text',
value: hoverText, value: hoverText,
contents: hoverText contents: hoverText
}, },
@ -113,9 +113,9 @@ const printHelp = (c) => {
) )
} }
const permListFormat = [] const permListFormat = []
permList.forEach((item, i)=>{ permList.forEach((item, i) => {
permListFormat.push({ permListFormat.push({
translate: i === permList.length - 1 ? "%s" : "%s ", translate: i === permList.length - 1 ? '%s' : '%s ',
color: colorList[i], color: colorList[i],
with: [ with: [
item item
@ -127,7 +127,7 @@ const printHelp = (c) => {
translate: '%s %s', translate: '%s %s',
with: [ with: [
{ {
translate: "%s (%s):", translate: '%s (%s):',
with: [ with: [
getMessage(c.lang, 'command.help.cmdList'), getMessage(c.lang, 'command.help.cmdList'),
permListFormat permListFormat

View file

@ -7,7 +7,7 @@ module.exports = {
if (c.bot.host.options && c.bot.host.options.hidden) { if (c.bot.host.options && c.bot.host.options.hidden) {
host = 'localhost' // Makes hidden servers appear as localhost host = 'localhost' // Makes hidden servers appear as localhost
port = '25565' port = '25565'
} else if(c.bot.host.options && c.bot.host.options.displayAsIPv6){ } else if (c.bot.host.options && c.bot.host.options.displayAsIPv6) {
host = `[${host}]` host = `[${host}]`
} }
const json = { const json = {
@ -43,7 +43,7 @@ module.exports = {
color: c.colors.primary color: c.colors.primary
}, },
{ {
text: c.args.join(' ').slice(0,512) text: c.args.join(' ').slice(0, 512)
} }
], ],
color: 'white' color: 'white'

View file

@ -1,7 +1,7 @@
module.exports = { module.exports = {
execute: (c) => { execute: (c) => {
if (c.args[0].startsWith('/') && c.verify < 1) return if (c.args[0].startsWith('/') && c.verify < 1) return
c.bot.chat(c.args.join(' ').slice(0,512)) c.bot.chat(c.args.join(' ').slice(0, 512))
}, },
consoleIndex: true, consoleIndex: true,
aliases: ['echo'] aliases: ['echo']

View file

@ -70,7 +70,7 @@ const createBot = function createBot (host, oldId) {
} }
bot.host = host bot.host = host
if(bot.host.host.includes(":")){ if (bot.host.host.includes(':')) {
bot.host.options.displayAsIPv6 = true bot.host.options.displayAsIPv6 = true
} }
bot.interval = {} bot.interval = {}
@ -80,7 +80,7 @@ const createBot = function createBot (host, oldId) {
} }
bot.displayChat = (type, subtype, msg) => { bot.displayChat = (type, subtype, msg) => {
if(settings.displaySubtypesToConsole){ if (settings.displaySubtypesToConsole) {
console.log(`[${bot.id}] [${type}] [${subtype}] ${msg}`) console.log(`[${bot.id}] [${type}] [${subtype}] ${msg}`)
} else { } else {
console.log(`[${bot.id}] [${type}] ${msg}`) console.log(`[${bot.id}] [${type}] ${msg}`)

View file

@ -44,7 +44,7 @@ module.exports = {
}) })
b._client.on('profileless_chat', (data) => { b._client.on('profileless_chat', (data) => {
let messageType = b.messageTypes[data.type] let messageType = b.messageTypes[data.type]
if(messageType === undefined) messageType = {translation_key: "%s", parameters: ["content"]} if (messageType === undefined) messageType = { translation_key: '%s', parameters: ['content'] }
const json = { translate: messageType.translation_key, with: [] } const json = { translate: messageType.translation_key, with: [] }
messageType.parameters.forEach((item, i) => { messageType.parameters.forEach((item, i) => {
if (item === 'content') { if (item === 'content') {
@ -58,10 +58,10 @@ module.exports = {
for (const i in messageType.style) { for (const i in messageType.style) {
json[i] = messageType.style[i] json[i] = messageType.style[i]
} }
message = parsePlain(parse1204(data.message)) const message = parsePlain(parse1204(data.message))
uuid = b.findUUID(parsePlain(parse1204(data.name))) const uuid = b.findUUID(parsePlain(parse1204(data.name)))
nickname = b.findDisplayName(uuid) const nickname = b.findDisplayName(uuid)
username = parsePlain(parse1204(data.name)) const username = parsePlain(parse1204(data.name))
b.emit('chat_unparsed', { b.emit('chat_unparsed', {
json, json,
type: 'profileless', type: 'profileless',
@ -75,7 +75,7 @@ module.exports = {
b._client.on('player_chat', (data) => { b._client.on('player_chat', (data) => {
let messageType = b.messageTypes[data.type] let messageType = b.messageTypes[data.type]
if(messageType === undefined) messageType = {translation_key: "%s", parameters: ["content"]} if (messageType === undefined) messageType = { translation_key: '%s', parameters: ['content'] }
const json = { translate: messageType.translation_key, with: [] } const json = { translate: messageType.translation_key, with: [] }
messageType.parameters.forEach((item, i) => { messageType.parameters.forEach((item, i) => {
if (item === 'content') { if (item === 'content') {
@ -109,17 +109,16 @@ module.exports = {
b.emit('chat_unparsed', { b.emit('chat_unparsed', {
json, json,
type: 'system', type: 'system',
uuid: "00000000-0000-0000-0000-000000000000", uuid: '00000000-0000-0000-0000-000000000000',
message: "", message: '',
nickname: "", nickname: '',
username: "", username: '',
playerChatType: {} playerChatType: {}
}) })
}) })
b._client.on('chat', (data) => { // Legacy chat for versions <1.19 b._client.on('chat', (data) => { // Legacy chat for versions <1.19
const json = parse1204(data.message) const json = parse1204(data.message)
const parsed = parsePlain(json)
let nickname let nickname
let username let username
let message let message

View file

@ -1,46 +1,45 @@
const parsePlain = require('../../util/chatparse_plain.js') const parsePlain = require('../../util/chatparse_plain.js')
module.exports = { module.exports = {
parse: (data) => { parse: (data, b) => {
if(data.type == "system" || data.type == "legacy"){ if (data.type === 'system' || data.type === 'legacy') {
if(data.parsed) return if (data.parsed) return
if (data.json.translate === '%s %s %s' || data.json.translate === '[%s] %s %s') { if (data.json.translate === '%s %s %s' || data.json.translate === '[%s] %s %s') {
let subtype = 'chipmunkmod_'; let subtype = 'chipmunkmod_'
if(data.json.translate === '%s %s %s'){ if (data.json.translate === '%s %s %s') {
subtype += 'name3_' subtype += 'name3_'
} else if(data.json.translate === '[%s] %s %s'){ } else if (data.json.translate === '[%s] %s %s') {
subtype += 'chomens_' subtype += 'chomens_'
} }
subtype += `${data.type}` subtype += `${data.type}`
if (data.json.with && data.json.with[1] && data.json.with[2]) { if (data.json.with && data.json.with[1] && data.json.with[2]) {
const username = parsePlain(data.json.with[1]) const username = parsePlain(data.json.with[1])
const uuid = b.findUUID(username) const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid) const nickname = b.findDisplayName(uuid)
const message = parsePlain(data.json.with[2].extra) const message = parsePlain(data.json.with[2].extra)
data.parsed = true data.parsed = true
b.emit('chat', { b.emit('chat', {
json: data.json, json: data.json,
type: data.type, type: data.type,
subtype: subtype, subtype,
uuid, uuid,
message, message,
nickname, nickname,
username username
}) })
} else { } else {
subtype += "_invalid" subtype += '_invalid'
b.emit('chat', { b.emit('chat', {
json: data.json, json: data.json,
type: data.type, type: data.type,
subtype: subtype, subtype,
uuid: '00000000-0000-0000-0000-000000000000', uuid: '00000000-0000-0000-0000-000000000000',
message: '', message: '',
nickname: '', nickname: '',
username: '' username: ''
}) })
data.parsed = true data.parsed = true
}
} }
} }
}
} }
} }

View file

@ -1,24 +1,23 @@
const parsePlain = require('../../util/chatparse_plain.js') const parsePlain = require('../../util/chatparse_plain.js')
module.exports = { module.exports = {
parse: (data) => { parse: (data, b) => {
if(data.type == "system" || data.type == "legacy"){ if (data.type === 'system' || data.type === 'legacy') {
if(data.parsed) return if (data.parsed) return
if (data.json.extra && data.json.extra[4] && data.json.extra[3] && data.json.extra[5] && data.json.extra[4].text === ' » ') { // ChipmunkMod format - m_c_player if (data.json.extra && data.json.extra[4] && data.json.extra[3] && data.json.extra[5] && data.json.extra[4].text === ' » ') { // ChipmunkMod format - m_c_player
const username = parsePlain(data.json.extra[3]) const username = parsePlain(data.json.extra[3])
const uuid = b.findUUID(username) const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid) const nickname = b.findDisplayName(uuid)
const message = parsePlain(data.json.extra[5]) const message = parsePlain(data.json.extra[5])
b.emit('chat', { b.emit('chat', {
json, json: data.json,
type: data.type, type: data.type,
subtype: `chipmunkmod_mcp_${data.type}`. subtype: `chipmunkmod_mcp_${data.type}`,
uuid, uuid,
message, message,
nickname, nickname,
username username
}) })
}
} }
}
} }
} }

View file

@ -1,28 +1,27 @@
const parsePlain = require('../../util/chatparse_plain.js') const parsePlain = require('../../util/chatparse_plain.js')
module.exports = { module.exports = {
parse: (data) => { parse: (data, b) => {
if(data.type == "profileless"){ if (data.type === 'profileless') {
if(data.parsed) return if (data.parsed) return
if (data.playerChatType.translation_key === '%s') { if (data.playerChatType.translation_key === '%s') {
const parsed = parsePlain(data.json) const parsed = parsePlain(data.json)
const split = parsed.split(': ') const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0] const chatName = split.splice(0, 1)[0]
const chatNameSplit = chatName.split(' ') const chatNameSplit = chatName.split(' ')
nickname = chatNameSplit[chatNameSplit.length - 1] const nickname = chatNameSplit[chatNameSplit.length - 1]
username = b.findRealName(chatName) const username = b.findRealName(chatName)
uuid = b.findUUID(username) const uuid = b.findUUID(username)
message = split.join(': ') const message = split.join(': ')
b.emit('chat', { b.emit('chat', {
json: data.json, json: data.json,
type: data.type, type: data.type,
subtype: "extras_profileless", subtype: 'extras_profileless',
uuid, uuid,
message, message,
nickname, nickname,
username username
}) })
}
} }
}
} }
} }

View file

@ -1,19 +1,17 @@
module.exports = { module.exports = {
parse: (data) => { parse: (data, b) => {
if (data.type === 'player' || data.type === 'profileless') {
if(data.type == "player" || data.type == "profileless"){ if (data.parsed) return
if(data.parsed) return if (data.type === 'profileless' && data.playerChatType.translation_key === '%s') return
if (data.type == "profileless" && data.playerChatType.translation_key === '%s') return b.emit('chat', {
b.emit('chat', { json: data.json,
json: data.json, type: data.type,
type: data.type, subtype: `generic_${data.type}`,
subtype: `generic_${data.type}`, uuid: data.uuid,
uuid: data.uuid, message: data.message,
message: data.message, nickname: data.nickname,
nickname: data.nickname, username: data.username
username: data.username })
}) }
}
} }
} }

View file

@ -1,29 +1,27 @@
const parsePlain = require('../../util/chatparse_plain.js') const parsePlain = require('../../util/chatparse_plain.js')
module.exports = { module.exports = {
parse: (data) => { parse: (data, b) => {
if (data.type === 'system' || data.type === 'legacy') {
if(data.type == "system" || data.type == "legacy"){ if (data.parsed) return
if(data.parsed) return if (data.type === 'legacy' && data.json.translate === 'chat.type.text') return
if (data.type == "legacy" && data.json.translate === 'chat.type.text') return let subtype = `generic_${data.type}`
let subtype = `generic_${data.type}` if (data.type === 'legacy' && data.uuid) subtype += '_withuuid'
if(data.type == "legacy" && data.uuid) subtype += "_withuuid" const parsed = parsePlain(data.json)
const parsed = parsePlain(data.json) const split = parsed.split(': ')
const split = parsed.split(': ') const chatName = split.splice(0, 1)[0]
const chatName = split.splice(0, 1)[0] const chatNameSplit = chatName.split(' ')
const chatNameSplit = chatName.split(' ') const nickname = chatNameSplit[chatNameSplit.length - 1]
const nickname = chatNameSplit[chatNameSplit.length - 1] const username = b.findRealName(chatName)
const username = b.findRealName(chatName) const uuid = b.findUUID(username)
const uuid = b.findUUID(username) b.emit('chat', {
b.emit('chat', { json: data.json,
json: data.json, type: data.type,
type: data.type, subtype,
subtype, uuid,
uuid: uuid, message: split.join(': '),
message: split.join(': '), nickname,
nickname: nickname, username
username: username })
}) }
}
} }
} }

View file

@ -1,31 +1,29 @@
const parsePlain = require('../../util/chatparse_plain.js') const parsePlain = require('../../util/chatparse_plain.js')
module.exports = { module.exports = {
parse: (data) => { parse: (data, b) => {
if(data.type == "legacy"){ if (data.type === 'legacy') {
if(data.parsed) return if (data.parsed) return
let subtype = `vanilla_${data.type}` let subtype = `vanilla_${data.type}`
if(data.type == "legacy" && data.uuid) subtype += "_withuuid" if (data.type === 'legacy' && data.uuid) subtype += '_withuuid'
if (data.json.translate === 'chat.type.text') { // Servers without Extras chat if (data.json.translate === 'chat.type.text') { // Servers without Extras chat
let message; let message
let username; let username
let uuid; if (data.json.with && data.json.with.length >= 2) {
let nickname; message = parsePlain(data.json.with[1])
if (data.json.with && data.json.with.length >= 2) { username = parsePlain(data.json.with[0])
message = parsePlain(data.json.with[1])
username = parsePlain(data.json.with[0])
}
uuid = b.findUUID(username)
nickname = b.findDisplayName(uuid)
b.emit('chat', {
json: data.json,
type: data.type,
subtype: subtype,
uuid,
message,
nickname,
username
})
} }
const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid)
b.emit('chat', {
json: data.json,
type: data.type,
subtype,
uuid,
message,
nickname,
username
})
} }
}
} }
} }

View file

@ -1,7 +1,7 @@
const uuidToInt = require('../util/uuidtoint.js') const uuidToInt = require('../util/uuidtoint.js')
const plainParser = require('../util/chatparse_plain.js') const plainParser = require('../util/chatparse_plain.js')
const mcParser = require('../util/chatparse_mc.js') const mcParser = require('../util/chatparse_mc.js')
const protover = require("../util/getProtocolVersion.js") const protover = require('../util/getProtocolVersion.js')
const cs = { const cs = {
x: 4, x: 4,
y: 6, y: 6,
@ -9,7 +9,7 @@ const cs = {
} }
module.exports = { module.exports = {
load: function (b) { load: function (b) {
if(protover(b._client.version) < 386){ // 1.13-pre4 if (protover(b._client.version) < 386) { // 1.13-pre4
b.host.options.useChat = true // This does not support command blocks below 1.13 b.host.options.useChat = true // This does not support command blocks below 1.13
} }
b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 150000) b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 150000)

View file

@ -47,7 +47,7 @@ module.exports = {
consoleWrite(`[${b.id}] [info] ${msg}`) consoleWrite(`[${b.id}] [info] ${msg}`)
} }
b.displayChat = (type, subtype, msg) => { b.displayChat = (type, subtype, msg) => {
if(settings.displaySubtypesToConsole){ if (settings.displaySubtypesToConsole) {
consoleWrite(`[${b.id}] [${type}] [${subtype}] ${msg}`) consoleWrite(`[${b.id}] [${type}] [${subtype}] ${msg}`)
} else { } else {
consoleWrite(`[${b.id}] [${type}] ${msg}`) consoleWrite(`[${b.id}] [${type}] ${msg}`)

View file

@ -1,4 +1,4 @@
const protover = require("../util/getProtocolVersion.js") const protover = require('../util/getProtocolVersion.js')
module.exports = { module.exports = {
load: (b) => { load: (b) => {
b._client.on('login', () => { b._client.on('login', () => {
@ -9,8 +9,8 @@ module.exports = {
} }
}, 100) }, 100)
}) })
b.matcherRegex = /.{1,99}/g; b.matcherRegex = /.{1,99}/g
if(protover(b._client.version) >= 306){ // 16w38a if (protover(b._client.version) >= 306) { // 16w38a
b.matcherRegex = /.{1,255}/g b.matcherRegex = /.{1,255}/g
} }
b.chatqueue = [] b.chatqueue = []

View file

@ -1,5 +1,5 @@
const fs = require('fs') const fs = require('fs')
const settings = require("../settings.json") const settings = require('../settings.json')
const cmds = Object.create(null) const cmds = Object.create(null)
const bpl = fs.readdirSync('./commands') const bpl = fs.readdirSync('./commands')
for (const plugin of bpl) { for (const plugin of bpl) {
@ -8,7 +8,7 @@ for (const plugin of bpl) {
} }
try { try {
const commandName = plugin.split('.js')[0] const commandName = plugin.split('.js')[0]
if(commandName == "settings" && settings.userSettingsDisabled) continue if (commandName === 'settings' && settings.userSettingsDisabled) continue
cmds[commandName] = require(`../commands/${plugin}`) cmds[commandName] = require(`../commands/${plugin}`)
if (cmds[commandName].level === undefined) { if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0 cmds[commandName].level = 0