This commit is contained in:
7cc5c4f330d47060 2024-08-04 01:41:32 -04:00
parent f7bde90840
commit 240fef6273
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:ACESPPwnsy88x7h9TZQ44QamQIRO9ngTeusTB6Kg9cY
19 changed files with 66 additions and 72 deletions

View file

@ -1,5 +1,5 @@
const version = require('../version.json') const version = require('../version.json')
const {getMessage} = require('../util/lang.js') const { getMessage } = require('../util/lang.js')
const botVersion = require('../util/version.js') const botVersion = require('../util/version.js')
module.exports = { module.exports = {
execute: function (c) { execute: function (c) {
@ -28,10 +28,10 @@ module.exports = {
} }
] ]
}) })
if(version.isPreRelease){ if (version.isPreRelease) {
c.reply({ c.reply({
text: getMessage(c.lang, 'command.about.preRelease'), text: getMessage(c.lang, 'command.about.preRelease'),
color: c.colors.secondary, color: c.colors.secondary
}) })
} }
c.reply({ text: '' }) c.reply({ text: '' })
@ -55,7 +55,7 @@ module.exports = {
text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser') text: getMessage(c.lang, 'command.about.sourceCode.openInBrowser')
} }
} }
}, }
] ]
}) })
c.reply({ text: '' }) c.reply({ text: '' })

View file

@ -1,4 +1,4 @@
const {getMessage} = require('../util/lang.js') const { getMessage } = require('../util/lang.js')
module.exports = { module.exports = {
execute: (c) => { execute: (c) => {
const subcmd = c.args.splice(0, 1)[0] const subcmd = c.args.splice(0, 1)[0]

View file

@ -1,7 +1,7 @@
const fs = require('fs') const fs = require('fs')
const cmds = Object.create(null) const cmds = Object.create(null)
const bpl = fs.readdirSync('./commands') const bpl = fs.readdirSync('./commands')
const {getMessage} = require('../util/lang.js') const { getMessage } = require('../util/lang.js')
const sortHelp = function sortHelp (c1, c2) { const sortHelp = function sortHelp (c1, c2) {
const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0 const level1 = cmds[c1.with[0]].level ? cmds[c1.with[0]].level : 0
@ -15,7 +15,7 @@ for (const i in bpl) { // Built-in loadCMD to the help command, to prevent circu
} }
try { try {
const commandName = bpl[i].split('.js')[0] const commandName = bpl[i].split('.js')[0]
if(commandName != "help"){ if (commandName !== 'help') {
cmds[commandName] = require(`./${bpl[i]}`) cmds[commandName] = require(`./${bpl[i]}`)
if (cmds[commandName].level === undefined) { if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0 cmds[commandName].level = 0
@ -65,7 +65,7 @@ const printHelp = (c) => {
} }
const printCmdHelp = (c) => { const printCmdHelp = (c) => {
const cmd=c.args[0]; const cmd = c.args[0]
if (!cmds[cmd]) { if (!cmds[cmd]) {
c.reply({ text: getMessage(c.lang, 'command.help.noCommand') }) c.reply({ text: getMessage(c.lang, 'command.help.noCommand') })
return return
@ -134,12 +134,12 @@ module.exports = {
] ]
} }
cmds.help = module.exports; // Placed after to ensure that the correct values are added to cmds cmds.help = module.exports // Placed after to ensure that the correct values are added to cmds
if (cmds.help.level === undefined) { if (cmds.help.level === undefined) {
cmds.help.level = 0 cmds.help.level = 0
} }
for (const i in cmds){ for (const i in cmds) {
if (cmds[i].aliases) { if (cmds[i].aliases) {
for (const j in cmds[i].aliases) { for (const j in cmds[i].aliases) {
cmds[cmds[i].aliases[j]] = { cmds[cmds[i].aliases[j]] = {

View file

@ -1,6 +1,6 @@
const os = require('os') const os = require('os')
const cp = require('child_process') const cp = require('child_process')
const {getMessage,formatTime} = require('../util/lang.js') const { getMessage, formatTime } = require('../util/lang.js')
const fs = require('fs') const fs = require('fs')
const botVersion = require('../util/version.js') const botVersion = require('../util/version.js')
const gr = function (l, text, value, color) { const gr = function (l, text, value, color) {

View file

@ -1,4 +1,4 @@
const {getMessage} = require('../util/lang.js') const { getMessage } = require('../util/lang.js')
module.exports = { module.exports = {
execute: function (c) { execute: function (c) {
let uuid let uuid

View file

@ -36,7 +36,7 @@ const createBot = function createBot (host, oldId) {
host: host.host, host: host.host,
port: host.port ? host.port : 25565, port: host.port ? host.port : 25565,
username: generateUser(host.options.legalName), username: generateUser(host.options.legalName),
version: host.version?host.version:settings.version_mc version: host.version ? host.version : settings.version_mc
}) })
if (typeof oldId !== 'undefined') { if (typeof oldId !== 'undefined') {
for (const i in module.exports.bot[oldId].interval) { for (const i in module.exports.bot[oldId].interval) {
@ -58,7 +58,7 @@ const createBot = function createBot (host, oldId) {
bot.info = (msg) => { bot.info = (msg) => {
console.log(`[${bot.id}] [info] ${msg}`) console.log(`[${bot.id}] [info] ${msg}`)
} }
bot.displayChat = (type, msg) => { bot.displayChat = (type, msg) => {
console.log(`[${bot.id}] [${type}] ${msg}`) console.log(`[${bot.id}] [${type}] ${msg}`)
} }

View file

@ -1,5 +1,4 @@
const settings = require('../settings.json') const settings = require('../settings.json')
const console2 = require('./console.js')
const parsePlain = require('../util/chatparse_plain.js') 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/chatparse_1204.js') const parse1204 = require('../util/chatparse_1204.js')
@ -76,14 +75,14 @@ module.exports = {
const parsed = parsePlain(json) const parsed = parsePlain(json)
let chatName let chatName
let username let username
let message; let message
let uuid; let uuid
if(b.host.options.isVanilla && json.translate === "chat.type.text"){ // Servers without Extras chat if (b.host.options.isVanilla && json.translate === 'chat.type.text') { // Servers without Extras chat
if(json.with && json.with.length>=2){ if (json.with && json.with.length >= 2) {
message = parsePlain(json.with[1]); message = parsePlain(json.with[1])
username = parsePlain(json.with[0]); username = parsePlain(json.with[0])
} }
uuid = b.findUUID(username); uuid = b.findUUID(username)
} else { // Servers with Extras chat, such as Kaboom } else { // Servers with Extras chat, such as Kaboom
const split = parsed.split(': ') const split = parsed.split(': ')
message = split.join(': ') message = split.join(': ')
@ -96,11 +95,11 @@ module.exports = {
b.on('chat', (data) => { b.on('chat', (data) => {
const msgConsole = parseConsole(data.json) const msgConsole = parseConsole(data.json)
const msgPlain = parsePlain(data.json) const msgPlain = parsePlain(data.json)
if(settings.logJSONmessages) console.log(data.json) if (settings.logJSONmessages) console.log(data.json)
if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return if (msgPlain.endsWith('\n\n\n\n\nThe chat has been cleared')) return
if (msgPlain.startsWith('Command set: ')) return if (msgPlain.startsWith('Command set: ')) return
b.emit('plainchat', msgPlain) b.emit('plainchat', msgPlain)
b.displayChat(data.type,`${msgConsole}\x1b[0m`) b.displayChat(data.type, `${msgConsole}\x1b[0m`)
const fullCommand = data.message const fullCommand = data.message
for (const i in b.prefix) { for (const i in b.prefix) {

View file

@ -1,8 +1,8 @@
const Command = require('../util/Command.js') const Command = require('../util/Command.js')
const hashcheck = require('../util/hashcheck.js') const hashcheck = require('../util/hashcheck.js')
const settings = require('../settings.json') const settings = require('../settings.json')
const {getMessage} = require('../util/lang.js') const { getMessage } = require('../util/lang.js')
const cmds = require("../util/commands.js") const cmds = require('../util/commands.js')
module.exports = { module.exports = {
load: (b) => { load: (b) => {

View file

@ -97,11 +97,11 @@ module.exports = {
} else { } else {
finalname = uuid finalname = uuid
} }
let tellrawCommand; let tellrawCommand
if(b.host.options.isVanilla){ if (b.host.options.isVanilla) {
tellrawCommand = "tellraw"; tellrawCommand = 'tellraw'
} else { } else {
tellrawCommand = "minecraft:tellraw"; tellrawCommand = 'minecraft:tellraw'
} }
b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`) b.ccq.push(`/${tellrawCommand} ${finalname} ${JSON.stringify(message)}`)
} }

View file

@ -1,7 +1,7 @@
const readln = require('readline') const readln = require('readline')
const index = require('../index.js') const index = require('../index.js')
const ConsoleCommand = require('../util/ConsoleCommand.js') const ConsoleCommand = require('../util/ConsoleCommand.js')
const cmds = require("../util/commands.js") const cmds = require('../util/commands.js')
const rl = readln.createInterface({ const rl = readln.createInterface({
input: process.stdin, input: process.stdin,
output: process.stdout, output: process.stdout,

View file

@ -10,11 +10,11 @@ module.exports = {
} else if (data.data[i].UUID) { } else if (data.data[i].UUID) {
uuid = data.data[i].UUID uuid = data.data[i].UUID
} }
let displayName; let displayName
if(data.data[i].displayName !== undefined){ if (data.data[i].displayName !== undefined) {
displayName = data.data[i].displayName; displayName = data.data[i].displayName
} else { } else {
displayName = "Undefined!" displayName = 'Undefined!'
} }
if (data.data[i].player && data.data[i].player.name !== undefined) { if (data.data[i].player && data.data[i].player.name !== undefined) {
buffer2[uuid] = { realName: data.data[i].player.name, displayName: displayName.plain } buffer2[uuid] = { realName: data.data[i].player.name, displayName: displayName.plain }

View file

@ -44,7 +44,7 @@ module.exports = {
}) })
// Commandspy // Commandspy
if(!b.host.options.isVanilla){ if (!b.host.options.isVanilla) {
b.add_sc_task('cspy', '/cspy on', true, true) b.add_sc_task('cspy', '/cspy on', true, true)
b.on('plainchat', (msg) => { b.on('plainchat', (msg) => {
if (msg === 'Successfully disabled CommandSpy') { if (msg === 'Successfully disabled CommandSpy') {
@ -54,7 +54,7 @@ module.exports = {
} }
}) })
} }
// Gamemode // Gamemode
b.add_sc_task('gamemode', '/minecraft:gamemode creative', true) b.add_sc_task('gamemode', '/minecraft:gamemode creative', true)
b._client.on('game_state_change', (p) => { b._client.on('game_state_change', (p) => {

View file

@ -1,10 +1,7 @@
// HOW TO WRITE CLASS JS // HOW TO WRITE CLASS JS
const index = require('../index.js') const index = require('../index.js')
const cmds = require('./commands.js')
const parse = require('../util/chatparse_console.js') const parse = require('../util/chatparse_console.js')
const settings = require('../settings.json') const settings = require('../settings.json')
const {getMessage} = require('../util/lang.js')
const lang = settings.defaultLang
class ConsoleCommand { class ConsoleCommand {
constructor (cmd, index2) { constructor (cmd, index2) {
this.send = () => {} // not needed for console this.send = () => {} // not needed for console

View file

@ -1,20 +1,20 @@
const settings = require('../settings.json'); const settings = require('../settings.json')
const lang = require('./mc_lang.js'); const lang = require('./mc_lang.js')
const _consoleColors = require("./consolecolors.json"); const _consoleColors = require('./consolecolors.json')
let consoleColors; let consoleColors
let consoleColors24; let consoleColors24
if(_consoleColors[settings.terminalMode]){ if (_consoleColors[settings.terminalMode]) {
consoleColors=_consoleColors[settings.terminalMode].fourBit consoleColors = _consoleColors[settings.terminalMode].fourBit
consoleColors24=_consoleColors[settings.terminalMode].twentyFourBit consoleColors24 = _consoleColors[settings.terminalMode].twentyFourBit
} else { } else {
consoleColors=_consoleColors.none.fourBit consoleColors = _consoleColors.none.fourBit
consoleColors24=_consoleColors.none.twentyFourBit consoleColors24 = _consoleColors.none.twentyFourBit
} }
const hexColorParser = (color) => { const hexColorParser = (color) => {
if(!consoleColors24.enabled || consoleColors24.bit!==24){ // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet if (!consoleColors24.enabled || consoleColors24.bit !== 24) { // Hex color parsing to the 8 bit and 4 bit modes has not been implemented yet
return ""; return ''
} }
let out = '\x1B[0;' let out = '\x1B[0;'
const redChannel = Number('0x' + color.slice(1, 3)) const redChannel = Number('0x' + color.slice(1, 3))
@ -29,7 +29,7 @@ const hexColorParser = (color) => {
} }
const processColor = (col, rcol) => { const processColor = (col, rcol) => {
let out; let out
if (col === 'reset') { if (col === 'reset') {
out = rcol out = rcol
} else if (col.startsWith('#')) { } else if (col.startsWith('#')) {
@ -55,7 +55,7 @@ const parse = function (_data, l = 0, resetColor = consoleColors.reset) {
data = _data data = _data
} }
let nkt = false let nkt = false
let out = "" let out = ''
if (data['']) { if (data['']) {
data.text = data[''] data.text = data['']
nkt = true nkt = true

View file

@ -1,4 +1,4 @@
const lang = require('./mc_lang.js'); const lang = require('./mc_lang.js')
const parse = function (_data, l = 0) { const parse = function (_data, l = 0) {
if (l >= 12) { if (l >= 12) {
@ -14,11 +14,9 @@ const parse = function (_data, l = 0) {
} else { } else {
data = _data data = _data
} }
let nkt = false let out = ''
let out = ""
if (data['']) { if (data['']) {
data.text = data[''] data.text = data['']
nkt = true
} }
if (data.text) { if (data.text) {
let _text = data.text let _text = data.text

View file

@ -26,4 +26,4 @@ for (const i in bpl) { // Built-in loadCMD
} }
} catch (e) { console.log(e) } } catch (e) { console.log(e) }
} }
module.exports=cmds; module.exports = cmds

View file

@ -35,24 +35,24 @@ module.exports = {
const days = Math.floor(time / 86400000) % 7 const days = Math.floor(time / 86400000) % 7
const weeks = Math.floor(time / 604800000) const weeks = Math.floor(time / 604800000)
if (weeks !== 0) { if (weeks !== 0) {
finalString += weeks; finalString += weeks
finalString += `${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")}` finalString += `${weeks === 1 ? getMessage(language, 'time.week') : getMessage(language, 'time.weekPlural')}`
} }
if (days !== 0) { if (days !== 0) {
finalString += days; finalString += days
finalString += `${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")}` finalString += `${days === 1 ? getMessage(language, 'time.day') : getMessage(language, 'time.dayPlural')}`
} }
if (hours !== 0) { if (hours !== 0) {
finalString += hours; finalString += hours
finalString += `${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")}` finalString += `${hours === 1 ? getMessage(language, 'time.hour') : getMessage(language, 'time.hourPlural')}`
} }
if (minutes !== 0) { if (minutes !== 0) {
finalString += minutes; finalString += minutes
finalString += `${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")}` finalString += `${minutes === 1 ? getMessage(language, 'time.minute') : getMessage(language, 'time.minutePlural')}`
} }
if (seconds !== 0) { if (seconds !== 0) {
finalString += seconds; finalString += seconds
finalString += `${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")}` finalString += `${seconds === 1 ? getMessage(language, 'time.second') : getMessage(language, 'time.secondPlural')}`
} }
return finalString return finalString
} }

View file

@ -1,6 +1,6 @@
const _lang = require('minecraft-data')('1.20.2').language; const _lang = require('minecraft-data')('1.20.2').language
const lang = Object.create(null) // Without constructor function const lang = Object.create(null) // Without constructor function
for (const i in _lang) { for (const i in _lang) {
lang[i] = _lang[i] lang[i] = _lang[i]
} }
module.exports=lang module.exports = lang

View file

@ -17,4 +17,4 @@ if (gitCommit) {
botVersion += ` (${gitCommit} - ${gitBranch})` botVersion += ` (${gitCommit} - ${gitBranch})`
} }
module.exports=botVersion; module.exports = botVersion