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

View file

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

View file

@ -1,7 +1,7 @@
const fs = require('fs')
const cmds = Object.create(null)
const bpl = fs.readdirSync('./commands')
const {getMessage} = require('../util/lang.js')
const { getMessage } = require('../util/lang.js')
const sortHelp = function sortHelp (c1, c2) {
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 {
const commandName = bpl[i].split('.js')[0]
if(commandName != "help"){
if (commandName !== 'help') {
cmds[commandName] = require(`./${bpl[i]}`)
if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0
@ -65,7 +65,7 @@ const printHelp = (c) => {
}
const printCmdHelp = (c) => {
const cmd=c.args[0];
const cmd = c.args[0]
if (!cmds[cmd]) {
c.reply({ text: getMessage(c.lang, 'command.help.noCommand') })
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) {
cmds.help.level = 0
}
for (const i in cmds){
for (const i in cmds) {
if (cmds[i].aliases) {
for (const j in cmds[i].aliases) {
cmds[cmds[i].aliases[j]] = {

View file

@ -1,6 +1,6 @@
const os = require('os')
const cp = require('child_process')
const {getMessage,formatTime} = require('../util/lang.js')
const { getMessage, formatTime } = require('../util/lang.js')
const fs = require('fs')
const botVersion = require('../util/version.js')
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 = {
execute: function (c) {
let uuid

View file

@ -36,7 +36,7 @@ const createBot = function createBot (host, oldId) {
host: host.host,
port: host.port ? host.port : 25565,
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') {
for (const i in module.exports.bot[oldId].interval) {
@ -58,7 +58,7 @@ const createBot = function createBot (host, oldId) {
bot.info = (msg) => {
console.log(`[${bot.id}] [info] ${msg}`)
}
bot.displayChat = (type, msg) => {
console.log(`[${bot.id}] [${type}] ${msg}`)
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,24 +35,24 @@ module.exports = {
const days = Math.floor(time / 86400000) % 7
const weeks = Math.floor(time / 604800000)
if (weeks !== 0) {
finalString += weeks;
finalString += `${weeks === 1 ? getMessage(language, "time.week") : getMessage(language, "time.weekPlural")}`
finalString += weeks
finalString += `${weeks === 1 ? getMessage(language, 'time.week') : getMessage(language, 'time.weekPlural')}`
}
if (days !== 0) {
finalString += days;
finalString += `${days === 1 ? getMessage(language, "time.day") : getMessage(language, "time.dayPlural")}`
finalString += days
finalString += `${days === 1 ? getMessage(language, 'time.day') : getMessage(language, 'time.dayPlural')}`
}
if (hours !== 0) {
finalString += hours;
finalString += `${hours === 1 ? getMessage(language, "time.hour") : getMessage(language, "time.hourPlural")}`
finalString += hours
finalString += `${hours === 1 ? getMessage(language, 'time.hour') : getMessage(language, 'time.hourPlural')}`
}
if (minutes !== 0) {
finalString += minutes;
finalString += `${minutes === 1 ? getMessage(language, "time.minute") : getMessage(language, "time.minutePlural")}`
finalString += minutes
finalString += `${minutes === 1 ? getMessage(language, 'time.minute') : getMessage(language, 'time.minutePlural')}`
}
if (seconds !== 0) {
finalString += seconds;
finalString += `${seconds === 1 ? getMessage(language, "time.second") : getMessage(language, "time.secondPlural")}`
finalString += seconds
finalString += `${seconds === 1 ? getMessage(language, 'time.second') : getMessage(language, 'time.secondPlural')}`
}
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
for (const i in _lang) {
lang[i] = _lang[i]
}
module.exports=lang
module.exports = lang

View file

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