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'
if (c.bot.id === i) message = 'command.about.serverListItem.thisServer'
let host = item.host.host
let port = item.host.port
if(item.host.options && item.host.options.displayAsIPv6){
const port = item.host.port
if (item.host.options && item.host.options.displayAsIPv6) {
host = `[${host}]`
}
c.reply({

View file

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

View file

@ -7,7 +7,7 @@ module.exports = {
if (c.bot.host.options && c.bot.host.options.hidden) {
host = 'localhost' // Makes hidden servers appear as localhost
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}]`
}
const json = {
@ -43,7 +43,7 @@ module.exports = {
color: c.colors.primary
},
{
text: c.args.join(' ').slice(0,512)
text: c.args.join(' ').slice(0, 512)
}
],
color: 'white'

View file

@ -1,7 +1,7 @@
module.exports = {
execute: (c) => {
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,
aliases: ['echo']

View file

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

View file

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

View file

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

View file

@ -1,24 +1,23 @@
const parsePlain = require('../../util/chatparse_plain.js')
module.exports = {
parse: (data) => {
if(data.type == "system" || data.type == "legacy"){
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
const username = parsePlain(data.json.extra[3])
const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid)
const message = parsePlain(data.json.extra[5])
b.emit('chat', {
json,
type: data.type,
subtype: `chipmunkmod_mcp_${data.type}`.
uuid,
message,
nickname,
username
})
}
parse: (data, b) => {
if (data.type === 'system' || data.type === 'legacy') {
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
const username = parsePlain(data.json.extra[3])
const uuid = b.findUUID(username)
const nickname = b.findDisplayName(uuid)
const message = parsePlain(data.json.extra[5])
b.emit('chat', {
json: data.json,
type: data.type,
subtype: `chipmunkmod_mcp_${data.type}`,
uuid,
message,
nickname,
username
})
}
}
}
}

View file

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

View file

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

View file

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

View file

@ -1,31 +1,29 @@
const parsePlain = require('../../util/chatparse_plain.js')
module.exports = {
parse: (data) => {
if(data.type == "legacy"){
if(data.parsed) return
let subtype = `vanilla_${data.type}`
if(data.type == "legacy" && data.uuid) subtype += "_withuuid"
if (data.json.translate === 'chat.type.text') { // Servers without Extras chat
let message;
let username;
let uuid;
let nickname;
if (data.json.with && data.json.with.length >= 2) {
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
})
parse: (data, b) => {
if (data.type === 'legacy') {
if (data.parsed) return
let subtype = `vanilla_${data.type}`
if (data.type === 'legacy' && data.uuid) subtype += '_withuuid'
if (data.json.translate === 'chat.type.text') { // Servers without Extras chat
let message
let username
if (data.json.with && data.json.with.length >= 2) {
message = parsePlain(data.json.with[1])
username = parsePlain(data.json.with[0])
}
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 plainParser = require('../util/chatparse_plain.js')
const mcParser = require('../util/chatparse_mc.js')
const protover = require("../util/getProtocolVersion.js")
const protover = require('../util/getProtocolVersion.js')
const cs = {
x: 4,
y: 6,
@ -9,7 +9,7 @@ const cs = {
}
module.exports = {
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.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}`)
}
b.displayChat = (type, subtype, msg) => {
if(settings.displaySubtypesToConsole){
if (settings.displaySubtypesToConsole) {
consoleWrite(`[${b.id}] [${type}] [${subtype}] ${msg}`)
} else {
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 = {
load: (b) => {
b._client.on('login', () => {
@ -9,8 +9,8 @@ module.exports = {
}
}, 100)
})
b.matcherRegex = /.{1,99}/g;
if(protover(b._client.version) >= 306){ // 16w38a
b.matcherRegex = /.{1,99}/g
if (protover(b._client.version) >= 306) { // 16w38a
b.matcherRegex = /.{1,255}/g
}
b.chatqueue = []

View file

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