This commit is contained in:
7cc5c4f330d47060 2024-08-24 10:15:39 -04:00
parent 54eb048e0b
commit 919bc90365
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
11 changed files with 87 additions and 87 deletions

View file

@ -112,7 +112,7 @@ const aboutServer = function (c) {
text: thisItem, text: thisItem,
color: c.colors.primary, color: c.colors.primary,
clickEvent: { clickEvent: {
action: "copy_to_clipboard", action: 'copy_to_clipboard',
value: thisItem value: thisItem
}, },
hoverEvent: { hoverEvent: {
@ -201,10 +201,10 @@ const aboutServer = function (c) {
} }
const displayServerList = function (c) { const displayServerList = function (c) {
index.bot.forEach((item, i)=>{ index.bot.forEach((item, i) => {
if (item.host.options && item.host.options.hidden && c.verify !== 3 && c.bot.id !== i) return if (item.host.options && item.host.options.hidden && c.verify !== 3 && c.bot.id !== i) return
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'
c.reply({ c.reply({
translate: getMessage(c.lang, message), translate: getMessage(c.lang, message),
color: c.colors.secondary, color: c.colors.secondary,
@ -217,7 +217,7 @@ const displayServerList = function (c) {
text: `${item.host.host}:${item.host.port}`, text: `${item.host.host}:${item.host.port}`,
color: c.colors.primary, color: c.colors.primary,
clickEvent: { clickEvent: {
action: "copy_to_clipboard", action: 'copy_to_clipboard',
value: `${item.host.host}:${item.host.port}` value: `${item.host.host}:${item.host.port}`
}, },
hoverEvent: { hoverEvent: {
@ -240,9 +240,9 @@ const displayServerList = function (c) {
module.exports = { module.exports = {
execute: function (c) { execute: function (c) {
let subcmd = c.args[0] let subcmd = c.args[0]
if(subcmd === "servers") subcmd = "serverlist" if (subcmd === 'servers') subcmd = 'serverlist'
if(c.cmdName === "serverinfo") subcmd = "server" if (c.cmdName === 'serverinfo') subcmd = 'server'
if(c.cmdName === "serverlist" || c.cmdName === "servers") subcmd = "serverlist" if (c.cmdName === 'serverlist' || c.cmdName === 'servers') subcmd = 'serverlist'
if (subcmd === 'server') { if (subcmd === 'server') {
aboutServer(c) aboutServer(c)
} else if (subcmd === 'serverlist') { } else if (subcmd === 'serverlist') {

View file

@ -44,7 +44,7 @@ module.exports = {
break break
} }
case 'list': case 'list':
c.bot.cloops.forEach((item, i)=>{ c.bot.cloops.forEach((item, i) => {
c.reply({ c.reply({
translate: getMessage(c.lang, 'command.cloop.list'), translate: getMessage(c.lang, 'command.cloop.list'),
color: c.colors.secondary, color: c.colors.secondary,

View file

@ -4,9 +4,9 @@ module.exports = {
execute: (c) => { execute: (c) => {
let host = c.host let host = c.host
let port = c.port let port = c.port
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'
} }
const json = { const json = {
translate: '[%s] %s: %s', translate: '[%s] %s: %s',
@ -14,12 +14,12 @@ module.exports = {
{ {
text: c.serverName, text: c.serverName,
hoverEvent: { hoverEvent: {
action: "show_text", action: 'show_text',
value: { value: {
translate: '%s: %s:%s', translate: '%s: %s:%s',
with: [ with: [
{ {
text: getMessage(c.lang, "command.netmsg.serverAddress"), text: getMessage(c.lang, 'command.netmsg.serverAddress'),
color: c.colors.primary color: c.colors.primary
}, },
{ {

View file

@ -2,7 +2,7 @@ const { languages, getMessage } = require('../util/lang.js')
const fs = require('fs') const fs = require('fs')
module.exports = { module.exports = {
execute: (c) => { execute: (c) => {
if(c.type == "console"){ if (c.type === 'console') {
c.reply({ c.reply({
text: getMessage(c.lang, 'command.settings.disabled.console'), text: getMessage(c.lang, 'command.settings.disabled.console'),
color: c.colors.secondary color: c.colors.secondary

View file

@ -14,7 +14,7 @@ module.exports = {
text: item, text: item,
color: c.colors.primary, color: c.colors.primary,
clickEvent: { clickEvent: {
action: "copy_to_clipboard", action: 'copy_to_clipboard',
value: item value: item
}, },
hoverEvent: { hoverEvent: {

View file

@ -1,14 +1,14 @@
const fs = require('fs') const fs = require('fs')
if (!fs.readdirSync('.').includes('settings.json')) { if (!fs.readdirSync('.').includes('settings.json')) {
console.log("Settings file is missing, using defaults.") console.log('Settings file is missing, using defaults.')
fs.copyFileSync("settings_example.json", "settings.json") fs.copyFileSync('settings_example.json', 'settings.json')
} }
if (!fs.readdirSync('.').includes('secret.json')) { if (!fs.readdirSync('.').includes('secret.json')) {
console.log("Secrets file is missing, using defaults.") console.log('Secrets file is missing, using defaults.')
fs.copyFileSync("secret_example.json", "secret.json") fs.copyFileSync('secret_example.json', 'secret.json')
console.log("Please change the hashing keys in the secrets file.") console.log('Please change the hashing keys in the secrets file.')
} }
const m = require('minecraft-protocol') const m = require('minecraft-protocol')

View file

@ -3,14 +3,14 @@ const parsePlain = require('../util/chatparse_plain.js')
const parseConsole = require('../util/chatparse_console.js') const parseConsole = require('../util/chatparse_console.js')
const parse1204 = require('../util/parseNBT.js') const parse1204 = require('../util/parseNBT.js')
const convertChatStyleItem = (item) => { const convertChatStyleItem = (item) => {
let output={}; const output = {}
for(const i in item){ for (const i in item) {
output[i] = item[i].value output[i] = item[i].value
} }
return output; return output
} }
const convertChatTypeItem = (item) => { const convertChatTypeItem = (item) => {
if(item.style){ if (item.style) {
return { return {
translation_key: item.translation_key.value, translation_key: item.translation_key.value,
parameters: item.parameters.value.value, parameters: item.parameters.value.value,
@ -26,11 +26,11 @@ const convertChatTypeItem = (item) => {
} }
module.exports = { module.exports = {
load: (b) => { load: (b) => {
b.messageTypes = []; b.messageTypes = []
b._client.on("registry_data",(data)=>{ b._client.on('registry_data', (data) => {
if(data.codec.value['minecraft:chat_type']){ if (data.codec.value['minecraft:chat_type']) {
b.messageTypes = data.codec.value['minecraft:chat_type'] b.messageTypes = data.codec.value['minecraft:chat_type']
const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value; const nbtItems = data.codec.value['minecraft:chat_type'].value.value.value.value
nbtItems.forEach((item, i) => { nbtItems.forEach((item, i) => {
b.messageTypes[i] = convertChatTypeItem(item.element.value.chat.value) b.messageTypes[i] = convertChatTypeItem(item.element.value.chat.value)
}) })
@ -38,24 +38,24 @@ module.exports = {
}) })
b._client.on('profileless_chat', (data) => { b._client.on('profileless_chat', (data) => {
const messageType = b.messageTypes[data.type] const messageType = b.messageTypes[data.type]
let 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') {
json.with[i] = parse1204(data.message) json.with[i] = parse1204(data.message)
} else if(item == "sender"){ } else if (item === 'sender') {
json.with[i] = parse1204(data.name) json.with[i] = parse1204(data.name)
} else if(item == "target"){ } else if (item === 'target') {
json.with[i] = parse1204(data.target) json.with[i] = parse1204(data.target)
} }
}) })
for(const i in messageType.style){ for (const i in messageType.style) {
json[i] = messageType.style[i] json[i] = messageType.style[i]
} }
let username = "" let username = ''
let nickname = "" let nickname = ''
let uuid = "00000000-0000-0000-0000-000000000000" let uuid = '00000000-0000-0000-0000-000000000000'
let message = "" let message = ''
if (messageType.translation_key == "%s") { if (messageType.translation_key === '%s') {
const parsed = parsePlain(json) const parsed = parsePlain(json)
const split = parsed.split(': ') const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0] const chatName = split.splice(0, 1)[0]
@ -63,7 +63,7 @@ module.exports = {
nickname = chatNameSplit[chatNameSplit.length - 1] nickname = chatNameSplit[chatNameSplit.length - 1]
username = b.findRealName(chatName) username = b.findRealName(chatName)
uuid = b.findUUID(username) uuid = b.findUUID(username)
message = split.join(": ") message = split.join(': ')
} else { } else {
message = parsePlain(parse1204(data.message)) message = parsePlain(parse1204(data.message))
uuid = b.findUUID(parsePlain(parse1204(data.name))) uuid = b.findUUID(parsePlain(parse1204(data.name)))
@ -71,7 +71,7 @@ module.exports = {
username = parsePlain(parse1204(data.name)) username = parsePlain(parse1204(data.name))
} }
b.emit('chat', { b.emit('chat', {
json: json, json,
type: 'profileless', type: 'profileless',
uuid, uuid,
message, message,
@ -82,25 +82,25 @@ module.exports = {
b._client.on('player_chat', (data) => { b._client.on('player_chat', (data) => {
const messageType = b.messageTypes[data.type] const messageType = b.messageTypes[data.type]
let 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') {
if(messageType.translation_key === "%s"){ if (messageType.translation_key === '%s') {
json.with[i] = parse1204(data.unsignedChatContent) json.with[i] = parse1204(data.unsignedChatContent)
} else { } else {
json.with[i] = data.plainMessage json.with[i] = data.plainMessage
} }
} else if(item == "sender"){ } else if (item === 'sender') {
json.with[i] = parse1204(data.networkName) json.with[i] = parse1204(data.networkName)
} else if(item == "target"){ } else if (item === 'target') {
json.with[i] = parse1204(data.networkTargetName) json.with[i] = parse1204(data.networkTargetName)
} }
}) })
for(const i in messageType.style){ for (const i in messageType.style) {
json[i] = messageType.style[i] json[i] = messageType.style[i]
} }
b.emit('chat', { b.emit('chat', {
json: json, json,
type: 'player', type: 'player',
uuid: data.senderUuid, uuid: data.senderUuid,
message: data.plainMessage, message: data.plainMessage,

View file

@ -11,19 +11,19 @@ if (_consoleColors[settings.terminalMode]) {
consoleColors = _consoleColors.none.fourBit consoleColors = _consoleColors.none.fourBit
consoleColors24 = _consoleColors.none.twentyFourBit consoleColors24 = _consoleColors.none.twentyFourBit
} }
const process8bitColorChannel = (value)=>{ const process8bitColorChannel = (value) => {
if(value < 65) return 0 if (value < 65) return 0
if(value < 115) return 1 if (value < 115) return 1
if(value < 155) return 2 if (value < 155) return 2
if(value < 195) return 3 if (value < 195) return 3
if(value < 235) return 4 if (value < 235) return 4
return 5 return 5
} }
const hexColorParser = (color) => { const hexColorParser = (color) => {
if (!consoleColors24.enabled || consoleColors24.bit === 4) { // Hex color parsing to the 4 bit mode has not been implemented yet if (!consoleColors24.enabled || consoleColors24.bit === 4) { // Hex color parsing to the 4 bit mode has not been implemented yet
return '' return ''
} }
if(consoleColors24.bit == 24){ if (consoleColors24.bit === 24) {
let out = '\x1B[0;' let out = '\x1B[0;'
const redChannel = Number(`0x${color.slice(1, 3)}`) const redChannel = Number(`0x${color.slice(1, 3)}`)
const greenChannel = Number(`0x${color.slice(3, 5)}`) const greenChannel = Number(`0x${color.slice(3, 5)}`)
@ -34,7 +34,7 @@ const hexColorParser = (color) => {
out += '48;2;0;0;0;' out += '48;2;0;0;0;'
} }
return out + `38;2;${redChannel};${greenChannel};${blueChannel}m` return out + `38;2;${redChannel};${greenChannel};${blueChannel}m`
} else if(consoleColors24.bit == 8){ } else if (consoleColors24.bit === 8) {
let out = '\x1B[0;' let out = '\x1B[0;'
const redChannel = Number(`0x${color.slice(1, 3)}`) const redChannel = Number(`0x${color.slice(1, 3)}`)
const greenChannel = Number(`0x${color.slice(3, 5)}`) const greenChannel = Number(`0x${color.slice(3, 5)}`)
@ -44,10 +44,10 @@ const hexColorParser = (color) => {
} else if (consoleColors24.lightMode && ((redChannel > 194 && greenChannel > 194 && blueChannel > 194) || greenChannel > 154)) { } else if (consoleColors24.lightMode && ((redChannel > 194 && greenChannel > 194 && blueChannel > 194) || greenChannel > 154)) {
out += '48;5;16;' out += '48;5;16;'
} }
let redOut = process8bitColorChannel(redChannel); const redOut = process8bitColorChannel(redChannel)
let greenOut = process8bitColorChannel(greenChannel); const greenOut = process8bitColorChannel(greenChannel)
let blueOut = process8bitColorChannel(blueChannel); const blueOut = process8bitColorChannel(blueChannel)
let colorValue = 16 + 36 * redOut + 6 * greenOut + blueOut const colorValue = 16 + 36 * redOut + 6 * greenOut + blueOut
return out + `38;5;${colorValue}m` return out + `38;5;${colorValue}m`
} }
} }
@ -101,7 +101,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
if (lang[trans] !== undefined) { if (lang[trans] !== undefined) {
trans = lang[trans].replace(/%%/g, '\ue123') trans = lang[trans].replace(/%%/g, '\ue123')
} }
if(data.with){ if (data.with) {
data.with.forEach((item, i) => { data.with.forEach((item, i) => {
const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor) const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))

View file

@ -1,23 +1,23 @@
const lang = require('./mc_lang.js') const lang = require('./mc_lang.js')
const consoleColors = { const consoleColors = {
dark_red: "§4", dark_red: '§4',
red: "§c", red: '§c',
dark_green: "§2", dark_green: '§2',
green: "§a", green: '§a',
gold: "§6", gold: '§6',
yellow: "§e", yellow: '§e',
dark_blue: "§1", dark_blue: '§1',
blue: "§9", blue: '§9',
dark_purple: "§5", dark_purple: '§5',
light_purple: "§d", light_purple: '§d',
dark_aqua: "§3", dark_aqua: '§3',
aqua: "§b", aqua: '§b',
black: "§0", black: '§0',
gray: "§7", gray: '§7',
dark_gray: "§8", dark_gray: '§8',
white: "§f", white: '§f',
reset: "§r§f" reset: '§r§f'
} }
const processColor = (col, rcol) => { const processColor = (col, rcol) => {
@ -67,7 +67,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
if (lang[trans] !== undefined) { if (lang[trans] !== undefined) {
trans = lang[trans].replace(/%%/g, '\ue123') trans = lang[trans].replace(/%%/g, '\ue123')
} }
if(data.with){ if (data.with) {
data.with.forEach((item, i) => { data.with.forEach((item, i) => {
const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor) const j2 = parse(item, l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805')) trans = trans.replace(/%s/, j2.replaceAll('%s', '\ud900\ud804').replaceAll('$s', '\ud900\ud805'))

View file

@ -21,8 +21,8 @@ const getMessage = function (l, msg, with2) {
} else if (languages['en-US'] && languages['en-US'][message] !== undefined) { } else if (languages['en-US'] && languages['en-US'][message] !== undefined) {
message = languages['en-US'][message].replace(/%%/g, '\ue123') message = languages['en-US'][message].replace(/%%/g, '\ue123')
} }
if (with2){ if (with2) {
with2.forEach((withItem, i)=>{ with2.forEach((withItem, i) => {
message = message.replace(/%s/, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) message = message.replace(/%s/, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
message = message.replaceAll(`%${+i + 1}$s`, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125')) message = message.replaceAll(`%${+i + 1}$s`, withItem.replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
}) })

View file

@ -32,12 +32,12 @@ const rsg = function (count) {
} }
const rsgLegal = function (count) { const rsgLegal = function (count) {
let output = '' let output = ''
if(Math.random()>0.5){ if (Math.random() > 0.5) {
output += "uwu_" output += 'uwu_'
} else { } else {
output += "owo_" output += 'owo_'
} }
output += crypto.randomBytes(count).toString("hex") output += crypto.randomBytes(count).toString('hex')
return output return output
} }
module.exports = function (legal) { module.exports = function (legal) {