Update every JavaScript source file

Linting!
This commit is contained in:
7cc5c4f330d47060 2024-07-28 02:37:31 -04:00
parent 7d89c2e2b3
commit ed53c4ac38
37 changed files with 1164 additions and 1174 deletions

131
index.js
View file

@ -1,80 +1,77 @@
const m = require("minecraft-protocol")
const settings = require("./settings.json")
const generateUser = require("./util/usergen.js")
const secret = require(settings.secret)
const EventEmitter = require("node:events")
const crypto = require("crypto")
const fs=require("fs")
const m = require('minecraft-protocol')
const settings = require('./settings.json')
const generateUser = require('./util/usergen.js')
const EventEmitter = require('node:events')
const fs = require('fs')
module.exports.bot=[];
module.exports.bot = []
const loadplug = (botno) => {
const botplug = []
const bpl = fs.readdirSync('plugins')
for (const i in bpl) {
if (!bpl[i].endsWith('.js')) {
continue
}
try {
botplug.push(require(`./plugins/${bpl[i]}`))
} catch (e) { console.log(e) }
const botplug = []
const bpl = fs.readdirSync('plugins')
for (const i in bpl) {
if (!bpl[i].endsWith('.js')) {
continue
}
botplug.forEach((plug) => {
try {
if (botno !== undefined) {
if (plug.loadBot) {
plug.loadBot(module.exports.bot[botno])
}
} else {
plug.load()
}
} catch (e) { console.log(e) }
})
try {
botplug.push(require(`./plugins/${bpl[i]}`))
} catch (e) { console.log(e) }
}
botplug.forEach((plug) => {
try {
if (botno !== undefined) {
if (plug.loadBot) {
plug.loadBot(module.exports.bot[botno])
}
} else {
plug.load()
}
} catch (e) { console.log(e) }
})
}
loadplug()
const createBot = function createBot(host,oldId){
if(host.options.disabled){
console.log(`Skipping server ${host.host}:${host.port}`)
return;
}
const bot = new EventEmitter();
bot._client = m.createClient({
host: host.host,
port: host.port ? host.port : 25565,
username: generateUser(host.options.legalName),
version: settings.version_mc
})
bot._client.on("success",()=>{
})
if(typeof oldId !== "undefined"){
for(const i in module.exports.bot[oldId].interval){
clearInterval(module.exports.bot[oldId].interval[i]);
}
delete module.exports.bot[oldId];
bot.id=oldId;
module.exports.bot[oldId]=bot;
console.log("Re-creating bot "+bot.id)
} else {
bot.id=module.exports.bot.length;
module.exports.bot.push(bot);
console.log("Creating bot "+bot.id)
const createBot = function createBot (host, oldId) {
if (host.options.disabled) {
console.log(`Skipping server ${host.host}:${host.port}`)
return
}
const bot = new EventEmitter()
bot._client = m.createClient({
host: host.host,
port: host.port ? host.port : 25565,
username: generateUser(host.options.legalName),
version: settings.version_mc
})
bot._client.on('success', () => {
})
if (typeof oldId !== 'undefined') {
for (const i in module.exports.bot[oldId].interval) {
clearInterval(module.exports.bot[oldId].interval[i])
}
delete module.exports.bot[oldId]
bot.id = oldId
module.exports.bot[oldId] = bot
console.log('Re-creating bot ' + bot.id)
} else {
bot.id = module.exports.bot.length
module.exports.bot.push(bot)
console.log('Creating bot ' + bot.id)
}
bot.host=host;
bot.interval={};
bot.host = host
bot.interval = {}
bot.info=(msg)=>{
console.log(`[${bot.id}] [info] ${msg}`)
}
loadplug(bot.id);
bot._client.on("error",(err)=>{
console.log(err)
})
bot.info = (msg) => {
console.log(`[${bot.id}] [info] ${msg}`)
}
loadplug(bot.id)
bot._client.on('error', (err) => {
console.log(err)
})
}
for(const i in settings.servers){
createBot(settings.servers[i]);
for (const i in settings.servers) {
createBot(settings.servers[i])
}
module.exports.createBot = createBot;
module.exports.createBot = createBot

View file

@ -1,101 +1,101 @@
const console2 = require("./console.js")
const parse = require("../util/chatparse.js")
const parse1204 = require("../util/chatparse_1204.js")
const messageTypes=[
"",
"chat.type.emote",
"commands.message.display.incoming",
"",
"",
"chat.type.announcement",
"",
""
const console2 = require('./console.js')
const parse = require('../util/chatparse.js')
const parse1204 = require('../util/chatparse_1204.js')
const messageTypes = [
'',
'chat.type.emote',
'commands.message.display.incoming',
'',
'',
'chat.type.announcement',
'',
''
]
module.exports={
load:()=>{
},
loadBot:(b)=>{
b._client.on("profileless_chat",(data)=>{
if(data.type==4){
const json=parse1204(data.message);
const parsed=parse(json)[1];
let split=parsed.split(": ");
const chatName = split.splice(0,1)[0]
const username=b.findRealName(chatName);
const uuid=b.findUUID(username)
b.emit("chat",{json,type:"profileless",uuid,message: split.join(": "), username})
} else {
b.emit("chat",{
json: {
translate: messageTypes[data.type],
color:data.type==2?"gray":"reset",
with:[
parse1204(data.name),
parse1204(data.message)
]
},
type:"profileless",
uuid:"00000000-0000-0000-0000-000000000000",
message: parse(parse1204(data.message))[1],
username:parse(parse1204(data.name))[1]
})
}
})
module.exports = {
load: () => {
b._client.on("player_chat",(data)=>{
if(data.type==4){
b.emit("chat",{json:parse1204(data.unsignedChatContent),type:"player",uuid:data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1]})
} else {
b.emit("chat",{
json: {
translate: messageTypes[data.type],
color:data.type==2?"gray":"reset",
with:[
parse1204(data.networkName),
data.plainMessage
]
},
type:"player",
uuid:data.senderUuid,
message: parse(data.plainMessage)[1],
username:parse(parse1204(data.networkName))[1]
})
}
},
loadBot: (b) => {
b._client.on('profileless_chat', (data) => {
if (data.type === 4) {
const json = parse1204(data.message)
const parsed = parse(json)[1]
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', { json, type: 'profileless', uuid, message: split.join(': '), username })
} else {
b.emit('chat', {
json: {
translate: messageTypes[data.type],
color: data.type === 2 ? 'gray' : 'reset',
with: [
parse1204(data.name),
parse1204(data.message)
]
},
type: 'profileless',
uuid: '00000000-0000-0000-0000-000000000000',
message: parse(parse1204(data.message))[1],
username: parse(parse1204(data.name))[1]
})
b._client.on("system_chat",(data)=>{
const json=parse1204(data.content);
const parsed=parse(json)[1];
let split=parsed.split(": ");
const chatName = split.splice(0,1)[0]
const username=b.findRealName(chatName);
const uuid=b.findUUID(username)
b.emit("chat",{json,type:"system",uuid, message: split.join(": "), username})
})
b._client.on("chat",(data)=>{ //Legacy chat
const json=parse1204(data.message);
const parsed=parse(json)[1];
let split=parsed.split(": ");
const chatName = split.splice(0,1)[0]
const username=b.findRealName(chatName);
const uuid=b.findUUID(username)
b.emit("chat",{json,type:"legacy",uuid:data.uuid?data.uuid:uuid, message: split.join(": "), username})
})
b.on("chat",(data)=>{
const msg=parse(data.json);
if(msg[1].endsWith("\n\n\n\n\nThe chat has been cleared")) return;
if(msg[1].startsWith("Command set: ")) return;
b.emit("plainchat",msg[1])
console2.write(`[${b.id}] [${data.type}] `+msg[0])
let fullCommand = data.message;
}
})
for(const i in b.prefix){
if(fullCommand.startsWith(b.prefix[i])){
const command=fullCommand.slice(b.prefix[i].length);
b.runCommand(data.username,data.uuid,command,b.prefix[i]);
}
}
b._client.on('player_chat', (data) => {
if (data.type === 4) {
b.emit('chat', { json: parse1204(data.unsignedChatContent), type: 'player', uuid: data.senderUuid, message: data.plainMessage, username: parse(parse1204(data.networkName))[1] })
} else {
b.emit('chat', {
json: {
translate: messageTypes[data.type],
color: data.type === 2 ? 'gray' : 'reset',
with: [
parse1204(data.networkName),
data.plainMessage
]
},
type: 'player',
uuid: data.senderUuid,
message: parse(data.plainMessage)[1],
username: parse(parse1204(data.networkName))[1]
})
},
parse
}
})
b._client.on('system_chat', (data) => {
const json = parse1204(data.content)
const parsed = parse(json)[1]
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', { json, type: 'system', uuid, message: split.join(': '), username })
})
b._client.on('chat', (data) => { // Legacy chat
const json = parse1204(data.message)
const parsed = parse(json)[1]
const split = parsed.split(': ')
const chatName = split.splice(0, 1)[0]
const username = b.findRealName(chatName)
const uuid = b.findUUID(username)
b.emit('chat', { json, type: 'legacy', uuid: data.uuid ? data.uuid : uuid, message: split.join(': '), username })
})
b.on('chat', (data) => {
const msg = parse(data.json)
if (msg[1].endsWith('\n\n\n\n\nThe chat has been cleared')) return
if (msg[1].startsWith('Command set: ')) return
b.emit('plainchat', msg[1])
console2.write(`[${b.id}] [${data.type}] ` + msg[0])
const fullCommand = data.message
for (const i in b.prefix) {
if (fullCommand.startsWith(b.prefix[i])) {
const command = fullCommand.slice(b.prefix[i].length)
b.runCommand(data.username, data.uuid, command, b.prefix[i])
}
}
})
},
parse
}

View file

@ -1,26 +1,26 @@
module.exports={
load:()=>{
},
loadBot:(b)=>{
b.cloops=[];
b.addCloop=function (command, rate){
b.cloops.push({
command,
rate,
interval: setInterval(()=>{b.ccq.push(command)},rate)
})
b.ccq.push(command)
}
b.removeCloop=function (index){
clearInterval(b.cloops[index].interval)
b.cloops.splice(index,1)
}
b.clearCloops=function (){
for(const i in b.cloops){
clearInterval(b.cloops[i].interval)
}
b.cloops=[];
}
module.exports = {
load: () => {
},
loadBot: (b) => {
b.cloops = []
b.addCloop = function (command, rate) {
b.cloops.push({
command,
rate,
interval: setInterval(() => { b.ccq.push(command) }, rate)
})
b.ccq.push(command)
}
}
b.removeCloop = function (index) {
clearInterval(b.cloops[index].interval)
b.cloops.splice(index, 1)
}
b.clearCloops = function () {
for (const i in b.cloops) {
clearInterval(b.cloops[i].interval)
}
b.cloops = []
}
}
}

View file

@ -1,187 +1,186 @@
const fs=require("fs");
const Command=require("../util/Command.js");
const hashcheck=require("../util/hashcheck.js");
const settings = require("../settings.json");
const getMessage = require('../util/lang.js');
let cmds=Object.create(null);
const sortHelp=function sortHelp(c1, c2){
const level1 = cmds[c1.with[1]].level?cmds[c1.with[1]].level:0;
const level2 = cmds[c2.with[1]].level?cmds[c2.with[1]].level:0;
return level1 - level2
const fs = require('fs')
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 = Object.create(null)
const sortHelp = function sortHelp (c1, c2) {
const level1 = cmds[c1.with[1]].level ? cmds[c1.with[1]].level : 0
const level2 = cmds[c2.with[1]].level ? cmds[c2.with[1]].level : 0
return level1 - level2
}
module.exports={
load:()=>{
module.exports.loadCMD();
},
loadBot:(b)=>{
b.prefix=settings.prefix;
b.lastCmd=0;
b.runCommand=(name, uuid, text, prefix)=>{
if(uuid=="00000000-0000-0000-0000-000000000000") return;
if(Date.now()-b.lastCmd<=1000) return;
b.lastCmd=Date.now();
const cmd=text.split(" ");
let lang=settings.defaultLang;
let verify=hashcheck(cmd);
if(verify>0){
text=cmd.slice(0,cmd.length-1).join(" ");
}
if(cmds[cmd[0].toLowerCase()]){
const command = cmds[cmd[0].toLowerCase()];
if(command.level!==undefined && command.level>verify){
b.tellraw(uuid,{
text:getMessage(lang,"command.disallowed.perms")
});
b.tellraw(uuid,{
text:getMessage(lang,"command.disallowed.perms.yourLevel",[verify+""])
});
b.tellraw(uuid,{
text:getMessage(lang,"command.disallowed.perms.cmdLevel",[command.level+""])
});
return;
}
try{
cmds[cmd[0].toLowerCase()].execute(new Command(uuid,name,"nick N/A",text,prefix,b,verify))
} catch(e) {
console.log(e);
b.tellraw(uuid,{
text:getMessage(lang,"command.error"),
color: "red",
hoverEvent:{
action: "show_text",
value:{
"text": e.stack
}
}
});
}
}
module.exports = {
load: () => {
module.exports.loadCMD()
},
loadBot: (b) => {
b.prefix = settings.prefix
b.lastCmd = 0
b.runCommand = (name, uuid, text, prefix) => {
if (uuid === '00000000-0000-0000-0000-000000000000') return
if (Date.now() - b.lastCmd <= 1000) return
b.lastCmd = Date.now()
const cmd = text.split(' ')
const lang = settings.defaultLang
const verify = hashcheck(cmd)
if (verify > 0) {
text = cmd.slice(0, cmd.length - 1).join(' ')
}
if (cmds[cmd[0].toLowerCase()]) {
const command = cmds[cmd[0].toLowerCase()]
if (command.level !== undefined && command.level > verify) {
b.tellraw(uuid, {
text: getMessage(lang, 'command.disallowed.perms')
})
b.tellraw(uuid, {
text: getMessage(lang, 'command.disallowed.perms.yourLevel', [verify + ''])
})
b.tellraw(uuid, {
text: getMessage(lang, 'command.disallowed.perms.cmdLevel', [command.level + ''])
})
return
}
b.printHelp=(uuid,prefix,lang)=>{
let commandList=[];
for(const i in cmds){
if(cmds[i].hidden) continue;
let cmdColor;
switch (cmds[i].level){
case 0:
cmdColor = "green";
break;
case 1:
cmdColor = "red";
break;
case 2:
cmdColor = "dark_red";
break;
case 3:
cmdColor = "dark_gray";
break;
default:
cmdColor = "gray";
}
commandList.push(
{
translate: "%s%s ",
color: cmdColor,
with: [
prefix,
i
]
}
)
try {
cmds[cmd[0].toLowerCase()].execute(new Command(uuid, name, 'nick N/A', text, prefix, b, verify))
} catch (e) {
console.log(e)
b.tellraw(uuid, {
text: getMessage(lang, 'command.error'),
color: 'red',
hoverEvent: {
action: 'show_text',
value: {
text: e.stack
}
}
b.tellraw(uuid,{
translate: "%s: %s",
with: [
getMessage(lang,"command.help.cmdList"),
commandList.sort(sortHelp)
]
})
})
}
b.printCmdHelp=(uuid,cmd,lang,color)=>{
if(!cmds[cmd]){
b.tellraw(uuid,{text:getMessage(lang,"command.help.noCommand")});
return;
}
let usage=getMessage(lang,`command.${cmd}.usage`).split("||");
let desc=getMessage(lang,`command.${cmd}.desc`);
if(cmds[cmd].usage){
usage=cmds[cmd].usage.split("||");
}
if(cmds[cmd].desc){
desc=cmds[cmd].desc;
}
//b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])});
for(const i in usage){
b.tellraw(uuid,{
translate:getMessage(lang,"command.help.commandUsage"),
color: color.secondary,
with:[
{
text: cmd,
color: color.primary
},
{
text: usage[i],
color: color.primary
},
]
});
}
b.tellraw(uuid,{
translate:getMessage(lang,"command.help.commandDesc"),
color: color.secondary,
with:[
{
text: desc,
color: color.primary
}
]
});
const permsN=getMessage(lang,"command.help.permsNormal");
const permsT=getMessage(lang,"command.help.permsTrusted");
const permsO=getMessage(lang,"command.help.permsOwner");
const permsC=getMessage(lang,"command.help.permsConsole");
const rPerms=cmds[cmd].level?cmds[cmd].level:0;
b.tellraw(uuid,{
translate:getMessage(lang,"command.help.commandPerms"),
color: color.secondary,
with:[
{
text: [permsN,permsT,permsO,permsC][rPerms],
color: color.primary
}
]
});
}
}
b.printHelp = (uuid, prefix, lang) => {
const commandList = []
for (const i in cmds) {
if (cmds[i].hidden) continue
let cmdColor
switch (cmds[i].level) {
case 0:
cmdColor = 'green'
break
case 1:
cmdColor = 'red'
break
case 2:
cmdColor = 'dark_red'
break
case 3:
cmdColor = 'dark_gray'
break
default:
cmdColor = 'gray'
}
},
loadCMD:()=>{
const botplug = []
const bpl = fs.readdirSync('./plugins/commands')
for (const i in bpl) {
if (!bpl[i].endsWith('.js')) {
continue
commandList.push(
{
translate: '%s%s ',
color: cmdColor,
with: [
prefix,
i
]
}
)
}
b.tellraw(uuid, {
translate: '%s: %s',
with: [
getMessage(lang, 'command.help.cmdList'),
commandList.sort(sortHelp)
]
})
}
b.printCmdHelp = (uuid, cmd, lang, color) => {
if (!cmds[cmd]) {
b.tellraw(uuid, { text: getMessage(lang, 'command.help.noCommand') })
return
}
let usage = getMessage(lang, `command.${cmd}.usage`).split('||')
let desc = getMessage(lang, `command.${cmd}.desc`)
if (cmds[cmd].usage) {
usage = cmds[cmd].usage.split('||')
}
if (cmds[cmd].desc) {
desc = cmds[cmd].desc
}
// b.tellraw(uuid,{"text":getMessage(lang,"command.help.commandInfo",[cmd,usage,desc])});
for (const i in usage) {
b.tellraw(uuid, {
translate: getMessage(lang, 'command.help.commandUsage'),
color: color.secondary,
with: [
{
text: cmd,
color: color.primary
},
{
text: usage[i],
color: color.primary
}
try {
commandName=bpl[i].split(".js")[0];
cmds[commandName]=require(`./commands/${bpl[i]}`);
if(cmds[commandName].level === undefined){
cmds[commandName].level = 0;
}
console.log("Loaded command "+commandName);
if(cmds[commandName].aliases){
for(const j in cmds[commandName].aliases){
cmds[cmds[commandName].aliases[j]]={
execute:cmds[commandName].execute,
desc:"Alias to "+commandName,
usage:cmds[commandName].usage,
level:cmds[commandName].level,
hidden:true,
consoleIndex:cmds[commandName].consoleIndex
};
}
}
} catch (e) { console.log(e); }
]
})
}
b.tellraw(uuid, {
translate: getMessage(lang, 'command.help.commandDesc'),
color: color.secondary,
with: [
{
text: desc,
color: color.primary
}
]
})
const permsN = getMessage(lang, 'command.help.permsNormal')
const permsT = getMessage(lang, 'command.help.permsTrusted')
const permsO = getMessage(lang, 'command.help.permsOwner')
const permsC = getMessage(lang, 'command.help.permsConsole')
const rPerms = cmds[cmd].level ? cmds[cmd].level : 0
b.tellraw(uuid, {
translate: getMessage(lang, 'command.help.commandPerms'),
color: color.secondary,
with: [
{
text: [permsN, permsT, permsO, permsC][rPerms],
color: color.primary
}
]
})
}
},
loadCMD: () => {
const bpl = fs.readdirSync('./plugins/commands')
for (const i in bpl) {
if (!bpl[i].endsWith('.js')) {
continue
}
try {
const commandName = bpl[i].split('.js')[0]
cmds[commandName] = require(`./commands/${bpl[i]}`)
if (cmds[commandName].level === undefined) {
cmds[commandName].level = 0
}
},
cmds
console.log('Loaded command ' + commandName)
if (cmds[commandName].aliases) {
for (const j in cmds[commandName].aliases) {
cmds[cmds[commandName].aliases[j]] = {
execute: cmds[commandName].execute,
desc: 'Alias to ' + commandName,
usage: cmds[commandName].usage,
level: cmds[commandName].level,
hidden: true,
consoleIndex: cmds[commandName].consoleIndex
}
}
}
} catch (e) { console.log(e) }
}
},
cmds
}

View file

@ -1,106 +1,106 @@
const uuidToInt = require('../util/uuidtoint.js')
module.exports = {
cs: 4,
cs_v: 6,
load: function () {
cs: 4,
cs_v: 6,
load: function () {
},
loadBot: function (b) {
b.interval.commandFill = setInterval(() => { if(b.sc_tasks["cc"]) b.sc_tasks["cc"].failed = 1; }, 60000)
b.ccq = []
b.blocknoX = 0
b.blocknoZ = 0
b.ccStarted = 0
b.blocknoY = 0
b.pos = { x: 0, y: 0, z: 0, correct: 0 }
},
loadBot: function (b) {
b.interval.commandFill = setInterval(() => { if (b.sc_tasks.cc) b.sc_tasks.cc.failed = 1 }, 60000)
b.ccq = []
b.blocknoX = 0
b.blocknoZ = 0
b.ccStarted = 0
b.blocknoY = 0
b.pos = { x: 0, y: 0, z: 0, correct: 0 }
b.advanceccq = function () {
if (b.ccq[0] && b.ccq[0].length != 0) {
b._client.write('update_command_block', {
command: b.ccq[0],
location: {
x: b.commandPos.x1 + b.blocknoX,
y: b.commandPos.y1 + b.blocknoY,
z: b.commandPos.z1 + b.blocknoZ
},
mode: 2,
flags: 1
})
b._client.write('update_command_block', {
command: b.ccq[0],
location: {
x: b.commandPos.x1 + b.blocknoX,
y: b.commandPos.y1 + b.blocknoY,
z: b.commandPos.z1 + b.blocknoZ
},
mode: 2,
flags: 5
})
b.blocknoX++
if (b.blocknoX == module.exports.cs) {
b.blocknoY++
b.blocknoX = 0
if (b.blocknoY == module.exports.cs_v) {
b.blocknoZ++
b.blocknoY = 0
if (b.blocknoZ == module.exports.cs) {
b.blocknoZ = 0
}
}
}
b.advanceccq = function () {
if (b.ccq[0] && b.ccq[0].length !== 0) {
b._client.write('update_command_block', {
command: b.ccq[0],
location: {
x: b.commandPos.x1 + b.blocknoX,
y: b.commandPos.y1 + b.blocknoY,
z: b.commandPos.z1 + b.blocknoZ
},
mode: 2,
flags: 1
})
b._client.write('update_command_block', {
command: b.ccq[0],
location: {
x: b.commandPos.x1 + b.blocknoX,
y: b.commandPos.y1 + b.blocknoY,
z: b.commandPos.z1 + b.blocknoZ
},
mode: 2,
flags: 5
})
b.blocknoX++
if (b.blocknoX === module.exports.cs) {
b.blocknoY++
b.blocknoX = 0
if (b.blocknoY === module.exports.cs_v) {
b.blocknoZ++
b.blocknoY = 0
if (b.blocknoZ === module.exports.cs) {
b.blocknoZ = 0
}
b.ccq.splice(0, 1)
}
b._client.on("login",()=>{
b.add_sc_task("cc",`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`,true,true)
b.add_sc_task("cc_size",`/gamerule commandModificationBlockLimit 32767`,true,false,true)
})
b.on('ccstart', () => {
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds
b.ccStarted = true;
})
b.on('chat', (data) => {
if(data.json.translate == 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.failed') ||
data.json.translate == 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.success')){
if (!b.ccStarted) {
b.emit('ccstart')
}
b.sc_tasks["cc"].failed = 0;
b.sc_tasks["cc_size"].failed = 0;
} else if(data.json.translate == 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate == 'commands.fill.toobig')){
b.sc_tasks["cc_size"].failed = 1;
}
})
b._client.on('position', function (a) {
if (!b.ccStarted) {
b.original_pos = { x: a.x, y: a.y, z: a.z }
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
} else {
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
if (a.x != b.original_pos.x || a.z != b.original_pos.z) {
b.original_pos = { x: a.x, y: a.y, z: a.z }
b.pos.correct = 0
b.sc_tasks["cc"].failed = 1;
}
}
b.commandPos = {
x1: Math.floor(a.x),
z1: Math.floor(a.z),
y1: 55
}
b._client.write('teleport_confirm', { teleportId: a.teleportId })
})
b.tellraw = (uuid, message) => {
let finalname = ''
if (uuid == '@a') {
finalname = '@a'
} else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) {
finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]`
} else {
finalname = uuid
}
b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`)
}
}
}
b.ccq.splice(0, 1)
}
b._client.on('login', () => {
b.add_sc_task('cc', '/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}', true, true)
b.add_sc_task('cc_size', '/gamerule commandModificationBlockLimit 32767', true, false, true)
})
b.on('ccstart', () => {
setTimeout(() => { b.interval.ccqi = setInterval(b.advanceccq, 3) }, 1000) // 1 Second and 3 Milliseconds
b.ccStarted = true
})
b.on('chat', (data) => {
if (data.json.translate === 'commands.fill.failed' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.failed') ||
data.json.translate === 'commands.fill.success' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.success')) {
if (!b.ccStarted) {
b.emit('ccstart')
}
b.sc_tasks.cc.failed = 0
b.sc_tasks.cc_size.failed = 0
} else if (data.json.translate === 'commands.fill.toobig' || (data.json.extra && data.json.extra[0] && data.json.extra[0].translate === 'commands.fill.toobig')) {
b.sc_tasks.cc_size.failed = 1
}
})
b._client.on('position', function (a) {
if (!b.ccStarted) {
b.original_pos = { x: a.x, y: a.y, z: a.z }
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
} else {
b.pos = { x: a.x, y: a.y, z: a.z, correct: 1 }
if (a.x !== b.original_pos.x || a.z !== b.original_pos.z) {
b.original_pos = { x: a.x, y: a.y, z: a.z }
b.pos.correct = 0
b.sc_tasks.cc.failed = 1
}
}
b.commandPos = {
x1: Math.floor(a.x),
z1: Math.floor(a.z),
y1: 55
}
b._client.write('teleport_confirm', { teleportId: a.teleportId })
})
b.tellraw = (uuid, message) => {
let finalname = ''
if (uuid === '@a') {
finalname = '@a'
} else if (uuid.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/)) {
finalname = `@a[nbt={UUID:[I;${uuidToInt(uuid)}]}]`
} else {
finalname = uuid
}
b.ccq.push(`/minecraft:tellraw ${finalname} ${JSON.stringify(message)}`)
}
}
}

View file

@ -1,73 +1,73 @@
const version = require("../../version.json")
const version = require('../../version.json')
const settings = require('../../settings.json')
const getMessage = require('../../util/lang.js')
const cp = require('child_process')
module.exports = {
execute: function (c) {
c.reply({
translate: getMessage(c.lang,"command.about.author"),
translate: getMessage(c.lang, 'command.about.author'),
color: c.colors.secondary,
with:[
with: [
{
text:settings.name,
text: settings.name,
color: c.colors.primary
}
]
});
c.reply({text:""});
let botVersion=version.bot;
let gitCommit;
})
c.reply({ text: '' })
const botVersion = version.bot
let gitCommit
try {
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0];
} catch(e){
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]
} catch (e) {
gitCommit = false
}
if(gitCommit){
if (gitCommit) {
c.reply({
translate:getMessage(c.lang,"command.about.version"),
translate: getMessage(c.lang, 'command.about.version'),
color: c.colors.secondary,
with:[
with: [
[
{
text:botVersion,
text: botVersion,
color: c.colors.primary
},
{
translate:" (%s)",
color: "white",
with:[
translate: ' (%s)',
color: 'white',
with: [
{
text:gitCommit,
text: gitCommit,
color: c.colors.primary
}
]
}
]
]
});
})
} else {
c.reply({
translate:getMessage(c.lang,"command.about.version"),
translate: getMessage(c.lang, 'command.about.version'),
color: c.colors.secondary,
with:[
with: [
{
text:botVersion,
text: botVersion,
color: c.colors.primary
}
]
});
})
}
c.reply({text:""});
c.reply({ text: '' })
c.reply({
translate:getMessage(c.lang,"command.about.serverinfo"),
translate: getMessage(c.lang, 'command.about.serverinfo'),
color: c.colors.secondary,
with: [
{
translate: "\"%s\"",
color: "white",
translate: '"%s"',
color: 'white',
with: [
{
text: "serverinfo",
text: 'serverinfo',
color: c.colors.primary
}
]
@ -75,5 +75,5 @@ module.exports = {
]
})
},
aliases: ["info"]
aliases: ['info']
}

View file

@ -1,7 +1,7 @@
module.exports={
execute: (c)=>{
c.bot.ccq.push(c.args.join(" "))
},
consoleIndex: true,
aliases: ["commandblock", "cmdblock"]
module.exports = {
execute: (c) => {
c.bot.ccq.push(c.args.join(' '))
},
consoleIndex: true,
aliases: ['commandblock', 'cmdblock']
}

View file

@ -1,88 +1,90 @@
const getMessage = require('../../util/lang.js')
module.exports={
execute: (c)=>{
const subcmd=c.args.splice(0,1)[0];
switch(subcmd){
case "add":
const rate=+(c.args.splice(0,1)[0]);
const command=c.args.join(" ");
if(rate<20){
c.reply({
text:getMessage(c.lang,"command.cloop.error.tooShort")
})
}
c.bot.addCloop(command,rate)
c.reply({
translate:getMessage(c.lang,"command.cloop.success.add"),
color: c.colors.secondary,
with:[
{
text:command,
color:c.colors.primary
},
{
text:rate+"",
color:c.colors.primary
},
]
})
break
case "remove":
const index=+c.args[0];
c.bot.removeCloop(c.args[0]);
c.reply({
translate:getMessage(c.lang,"command.cloop.success.remove"),
color: c.colors.secondary,
with:[
{
text:index+"",
color:c.colors.primary
}
]
})
break
case "list":
for(const i in c.bot.cloops){
c.reply({
translate:getMessage(c.lang,"command.cloop.list"),
color: c.colors.secondary,
with: [
{
text:i,
color:c.colors.primary
},
{
text:c.bot.cloops[i].command,
color:c.colors.primary
},
{
text:c.bot.cloops[i].rate+"",
color:c.colors.primary
}
]
})
}
break
case "clear":
c.bot.clearCloops();
c.reply({
text:getMessage(c.lang,"command.cloop.success.clear"),
color: c.colors.secondary
})
break
default:
c.reply({
translate:getMessage(c.lang,"command.cloop.error.subcommand"),
color: c.colors.secondary,
with:[
{
text:`${c.prefix}help cloop`,
color: c.colors.primary
}
]
})
module.exports = {
execute: (c) => {
const subcmd = c.args.splice(0, 1)[0]
switch (subcmd) {
case 'add': {
const rate = +(c.args.splice(0, 1)[0])
const command = c.args.join(' ')
if (rate < 20) {
c.reply({
text: getMessage(c.lang, 'command.cloop.error.tooShort')
})
}
},
consoleIndex: true,
level: 1
c.bot.addCloop(command, rate)
c.reply({
translate: getMessage(c.lang, 'command.cloop.success.add'),
color: c.colors.secondary,
with: [
{
text: command,
color: c.colors.primary
},
{
text: rate + '',
color: c.colors.primary
}
]
})
break
}
case 'remove': {
const index = +c.args[0]
c.bot.removeCloop(c.args[0])
c.reply({
translate: getMessage(c.lang, 'command.cloop.success.remove'),
color: c.colors.secondary,
with: [
{
text: index + '',
color: c.colors.primary
}
]
})
break
}
case 'list':
for (const i in c.bot.cloops) {
c.reply({
translate: getMessage(c.lang, 'command.cloop.list'),
color: c.colors.secondary,
with: [
{
text: i,
color: c.colors.primary
},
{
text: c.bot.cloops[i].command,
color: c.colors.primary
},
{
text: c.bot.cloops[i].rate + '',
color: c.colors.primary
}
]
})
}
break
case 'clear':
c.bot.clearCloops()
c.reply({
text: getMessage(c.lang, 'command.cloop.success.clear'),
color: c.colors.secondary
})
break
default:
c.reply({
translate: getMessage(c.lang, 'command.cloop.error.subcommand'),
color: c.colors.secondary,
with: [
{
text: `${c.prefix}help cloop`,
color: c.colors.primary
}
]
})
}
},
consoleIndex: true,
level: 1
}

View file

@ -1,11 +1,12 @@
const index=require("../../index.js") // Not used in the code, but may be used by users of the command
module.exports={
execute: (c)=>{
try{
console.log(eval(c.args.join(" ")));
}catch(e){
console.error(e);
}
},
level: 3
const index = require('../../index.js') // Not used in the code, but may be used by users of the command
module.exports = {
execute: (c) => {
try {
console.log(eval(c.args.join(' ')))
} catch (e) {
console.error(e)
}
},
level: 3
}

View file

@ -1,12 +1,12 @@
module.exports={
execute: (c)=>{
if(c.args.length>0){
c.bot.printCmdHelp(c.uuid,c.args[0],c.lang,c.colors);
} else {
c.bot.printHelp(c.uuid,c.prefix,c.lang,c.colors);
}
},
aliases: [
"heko" //Parker2991 request
]
module.exports = {
execute: (c) => {
if (c.args.length > 0) {
c.bot.printCmdHelp(c.uuid, c.args[0], c.lang, c.colors)
} else {
c.bot.printHelp(c.uuid, c.prefix, c.lang, c.colors)
}
},
aliases: [
'heko' // Parker2991 request
]
}

View file

@ -1,7 +1,7 @@
module.exports={
execute: (c)=>{
c.bot._client.end();
},
consoleIndex: true,
level: 2
module.exports = {
execute: (c) => {
c.bot._client.end()
},
consoleIndex: true,
level: 2
}

View file

@ -1,35 +1,35 @@
const {bot}=require("../../index.js");
module.exports={
execute: (c)=>{
const json={
translate: "[%s] %s: %s",
with:[
{
translate: "%s:%s",
with:[
{
text: c.host,
color: c.colors.primary
},
{
text: c.port+"",
color: c.colors.primary
}
],
color: c.colors.secondary
},
{
text: c.username,
color: c.colors.primary
},
{
text: c.args.join(" ")
},
],
color: "white"
}
for(const i in bot){
bot[i].tellraw("@a",json)
const { bot } = require('../../index.js')
module.exports = {
execute: (c) => {
const json = {
translate: '[%s] %s: %s',
with: [
{
translate: '%s:%s',
with: [
{
text: c.host,
color: c.colors.primary
},
{
text: c.port + '',
color: c.colors.primary
}
],
color: c.colors.secondary
},
{
text: c.username,
color: c.colors.primary
},
{
text: c.args.join(' ')
}
],
color: 'white'
}
for (const i in bot) {
bot[i].tellraw('@a', json)
}
}
}

View file

@ -1,7 +1,7 @@
module.exports={
execute: (c)=>{
c.bot.chat(`/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}'}`)
},
consoleIndex: true,
aliases: ["refillcore", "rc"]
module.exports = {
execute: (c) => {
c.bot.chat('/fill ~ 55 ~ ~3 60 ~3 command_block{CustomName:\'{"translate":"%s %s","with":[{"translate":"entity.minecraft.ender_dragon"},{"translate":"language.region"}],"color":"#FFAAEE"}\'}')
},
consoleIndex: true,
aliases: ['refillcore', 'rc']
}

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(" "))
},
consoleIndex: true
module.exports = {
execute: (c) => {
if (c.args[0].startsWith('/') && c.verify < 1) return
c.bot.chat(c.args.join(' '))
},
consoleIndex: true
}

View file

@ -2,9 +2,9 @@ const os = require('os')
const cp = require('child_process')
const settings = require('../../settings.json')
const timeformat = require('../../util/timeformat.js')
const version = require("../../version.json")
const version = require('../../version.json')
const getMessage = require('../../util/lang.js')
const fs=require("fs")
const fs = require('fs')
const gr = function (l, text, value, color) {
if (!color) color = 'white'
return {
@ -23,7 +23,7 @@ const gr = function (l, text, value, color) {
hoverEvent: {
action: 'show_text',
contents: {
text: getMessage(l,"copyText")
text: getMessage(l, 'copyText')
}
},
clickEvent: {
@ -33,67 +33,64 @@ const gr = function (l, text, value, color) {
}
}
const os2 = function (o2,l) {
const os2 = function (o2, l) {
switch (o2) {
case 'win32':
return os.version()
break
case 'android':
return getMessage(l,"command.serverinfo.os.android")
break
return getMessage(l, 'command.serverinfo.os.android')
case 'linux':
return getMessage(l,"command.serverinfo.os.linux",[os.release()])
break
return getMessage(l, 'command.serverinfo.os.linux', [os.release()])
default:
return o2
}
}
module.exports = {
execute: function (c) {
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os"), os2(process.platform,c.lang),c.colors))
if(os.cpus()[0]) c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.processor"), os.cpus()[0].model,c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.arch"), os.machine(),c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osUsername"), `${os.userInfo().username} (${os.userInfo().uid})`,c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.hostName"), os.hostname(),c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.workingDir"), process.cwd(),c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.runTime"), timeformat(process.uptime() * 1000),c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.upTime"), timeformat(os.uptime() * 1000),c.colors))
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.nodeVersion"), process.version,c.colors))
if (process.platform == 'linux' || process.platform == 'freebsd') {
try{
const osrelease = fs.readFileSync("/etc/os-release").toString("UTF-8").split("\n");
let osrelease2={};
for(const i in osrelease){
if(!osrelease[i].includes("=")) continue;
let osr_value=osrelease[i].split("=")[1];
if(osr_value.startsWith("\"") && osr_value.endsWith("\"")){osr_value=osr_value.slice(1,osr_value.length-1)};
osrelease2[osrelease[i].split("=")[0]]=osr_value;
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os'), os2(process.platform, c.lang), c.colors))
if (os.cpus()[0]) c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.processor'), os.cpus()[0].model, c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.arch'), os.machine(), c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osUsername'), `${os.userInfo().username} (${os.userInfo().uid})`, c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.hostName'), os.hostname(), c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.workingDir'), process.cwd(), c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.runTime'), timeformat(process.uptime() * 1000), c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.upTime'), timeformat(os.uptime() * 1000), c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.nodeVersion'), process.version, c.colors))
if (process.platform === 'linux' || process.platform === 'freebsd') {
try {
const osrelease = fs.readFileSync('/etc/os-release').toString('UTF-8').split('\n')
const osrelease2 = {}
for (const i in osrelease) {
if (!osrelease[i].includes('=')) continue
let osrvalue = osrelease[i].split('=')[1]
if (osrvalue.startsWith('"') && osrvalue.endsWith('"')) { osrvalue = osrvalue.slice(1, osrvalue.length - 1) };
osrelease2[osrelease[i].split('=')[0]] = osrvalue
}
if(osrelease2.PRETTY_NAME){
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.osRelease"), osrelease2.PRETTY_NAME,c.colors))
if (osrelease2.PRETTY_NAME) {
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.osRelease'), osrelease2.PRETTY_NAME, c.colors))
}
} catch(e){
c.reply({text:getMessage(c.lang,"command.serverinfo.osRelease.missing")})
} catch (e) {
c.reply({ text: getMessage(c.lang, 'command.serverinfo.osRelease.missing') })
}
} else if (process.platform == 'android') {
const android_version = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.version"), android_version,c.colors))
const dModel=cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0];
const dBrand=cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0];
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.os.android.model"), dBrand+" "+dModel,c.colors))
} else if (process.platform === 'android') {
const androidVersion = cp.execSync('getprop ro.build.version.release').toString('UTF-8').split('\n')[0]
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.version'), androidVersion, c.colors))
const dModel = cp.execSync('getprop ro.product.model').toString('UTF-8').split('\n')[0]
const dBrand = cp.execSync('getprop ro.product.brand').toString('UTF-8').split('\n')[0]
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.os.android.model'), dBrand + ' ' + dModel, c.colors))
}
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botName"), settings.name,c.colors))
let botVersion=version.bot;
let gitCommit;
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botName'), settings.name, c.colors))
let botVersion = version.bot
let gitCommit
try {
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0];
} catch(e){
gitCommit = cp.execSync('git rev-parse --short HEAD').toString('UTF-8').split('\n')[0]
} catch (e) {
gitCommit = false
}
if(gitCommit){
botVersion+=` (${gitCommit})`
if (gitCommit) {
botVersion += ` (${gitCommit})`
}
c.reply(gr(c.lang,getMessage(c.lang,"command.serverinfo.botVer"), botVersion,c.colors))
c.reply(gr(c.lang, getMessage(c.lang, 'command.serverinfo.botVer'), botVersion, c.colors))
}
}

View file

@ -1,7 +1,7 @@
module.exports={
execute: (c)=>{
process.exit(0);
},
aliases: ["restart", "exit"],
level: 2
module.exports = {
execute: (c) => {
process.exit(0)
},
aliases: ['restart', 'exit'],
level: 2
}

View file

@ -1,7 +1,7 @@
module.exports={
execute: (c)=>{
//Blank template
/*
module.exports = {
execute: (c) => {
// Blank template
/*
c.send(text, user?): Send text to all ("/tellraw @a")
c.reply(text): Send text to command sender
c.uuid: Unique identifier (UUID for Minecraft, Discord ID for Discord)
@ -15,12 +15,12 @@ module.exports={
c.lang: The language the player has selected, or the default if none
c.colors: The color palette the player has selected, or the default if none
*/
},
/*
},
/*
Command description and usage have been moved to the message files. The format for a basic command is:
"command.(name).usage": " <required> [optional]",
"command.(name).desc": "Insert description here...",
replacing (name) with the name of the new command.
replacing (name) with the name of the new command.
Some more complex commands may have messages of their own, which should be placed there too.
First, insert the following line near the top of the command's file (not in the execute function):
const getMessage = require('../../util/lang.js')
@ -35,8 +35,8 @@ module.exports={
cmdusage - desc
Extra information is inserted wherever there is a "%s" or a "%n$s", with n being the index of the item in the array.
*/
hidden: true, // To show the command on the help command list, remove this line (optional)
consoleIndex: true, // When run from console, the second argument will be a bot ID (optional)
aliases: ["example", "testing"], // Other command names that will work the same (optional)
level: 0 // Permission level required to run this command (optional)
hidden: true, // To show the command on the help command list, remove this line (optional)
consoleIndex: true, // When run from console, the second argument will be a bot ID (optional)
aliases: ['example', 'testing'], // Other command names that will work the same (optional)
level: 0 // Permission level required to run this command (optional)
}

View file

@ -1,11 +1,11 @@
module.exports={
execute: (c)=>{
c.reply({
text: c.verify+""
})
c.reply({
text: c.command
})
},
level: 1
module.exports = {
execute: (c) => {
c.reply({
text: c.verify + ''
})
c.reply({
text: c.command
})
},
level: 1
}

View file

@ -1,10 +1,9 @@
const readln = require('readline')
const index = require('../index.js')
const ConsoleCommand = require('../util/ConsoleCommand.js')
const fs = require('fs')
const newercommands = require('./command.js').cmds;
const newercommands = require('./command.js').cmds
let rl
function consoleWrite(text) {
function consoleWrite (text) {
readln.cursorTo(process.stdout, 0)
readln.clearLine(process.stdout, 0)
process.stdout.write(text + '\n')
@ -19,21 +18,21 @@ module.exports = {
})
rl.on('line', (l) => {
try {
if(newercommands[l.split(' ')[0].toLowerCase()]){
if(newercommands[l.split(' ')[0].toLowerCase()].consoleIndex){
let tmpcmd = l.split(' ');
const index2 = tmpcmd.splice(1,1)[0];
if (newercommands[l.split(' ')[0].toLowerCase()]) {
if (newercommands[l.split(' ')[0].toLowerCase()].consoleIndex) {
const tmpcmd = l.split(' ')
const index2 = tmpcmd.splice(1, 1)[0]
if (index2 === '*') {
for (let i = 0; i < index.bot.length; i++) {
const cmd = new ConsoleCommand(tmpcmd.join(' '),i);
const cmd = new ConsoleCommand(tmpcmd.join(' '), i)
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
}
} else {
const cmd = new ConsoleCommand(tmpcmd.join(' '),+index2);
const cmd = new ConsoleCommand(tmpcmd.join(' '), +index2)
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
}
} else {
const cmd = new ConsoleCommand(l,-2);
const cmd = new ConsoleCommand(l, -2)
newercommands[l.split(' ')[0].toLowerCase()].execute(cmd)
}
}
@ -44,8 +43,8 @@ module.exports = {
})
rl.prompt()
},
loadBot: (b)=>{
b.info=(msg)=>{
loadBot: (b) => {
b.info = (msg) => {
consoleWrite(`[${b.id}] [info] ${msg}`)
}
},

View file

@ -1,23 +1,22 @@
module.exports={
load:()=>{
},
loadBot:(b)=>{
b._client.on("login",()=>{
b.interval.chatQueue=setInterval(()=>{
if(b.chatqueue.length!=0){
b._client.chat(b.chatqueue[0]);
b.chatqueue.splice(0,1)
}
},150)
})
b.chatqueue=[];
b.chat=function chat(msg){
if(msg.length==0) return;
msg.match(/.{1,250}/g).forEach(element => {
b.chatqueue.push(element)
});
}
module.exports = {
load: () => {
},
loadBot: (b) => {
b._client.on('login', () => {
b.interval.chatQueue = setInterval(() => {
if (b.chatqueue.length !== 0) {
b._client.chat(b.chatqueue[0])
b.chatqueue.splice(0, 1)
}
}, 150)
})
b.chatqueue = []
b.chat = function chat (msg) {
if (msg.length === 0) return
msg.match(/.{1,250}/g).forEach(element => {
b.chatqueue.push(element)
})
}
}
}

View file

@ -1,49 +1,48 @@
const parse = require("../util/chatparse.js")
const parse1204 = require("../util/chatparse_1204.js")
module.exports={
load:()=>{
},
loadBot:(b)=>{
b.players={};
b._client.on("player_info",(data)=>{
console.log
let buffer2={};
for(const i in data.data){
let uuid;
if(data.data[i].uuid){
uuid=data.data[i].uuid
} else if(data.data[i].UUID){
uuid=data.data[i].UUID
}
if(data.data[i].player && data.data[i].player.name!==undefined){
buffer2[uuid]={realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1]}
} else if(data.data[i].name!==undefined){
buffer2[uuid]={realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1]}
} else if(data.data[i].displayName!==undefined){
buffer2[uuid]={displayName: parse(parse1204(data.data[i].displayName))[1]}
}
}
for(const uuid in buffer2){
if(!b.players[uuid]) b.players[uuid]={displayName:"",realName:""};
if(buffer2[uuid].displayName) b.players[uuid].displayName=buffer2[uuid].displayName;
if(buffer2[uuid].realName) b.players[uuid].realName=buffer2[uuid].realName;
}
})
b.findUUID=(name)=>{
for(const i in b.players){
if(b.players[i].realName==name){
return i;
}
}
return "00000000-0000-0000-0000-000000000000"
const parse = require('../util/chatparse.js')
const parse1204 = require('../util/chatparse_1204.js')
module.exports = {
load: () => {
},
loadBot: (b) => {
b.players = {}
b._client.on('player_info', (data) => {
const buffer2 = {}
for (const i in data.data) {
let uuid
if (data.data[i].uuid) {
uuid = data.data[i].uuid
} else if (data.data[i].UUID) {
uuid = data.data[i].UUID
}
b.findRealName=(name)=>{
for(const i in b.players){
if(b.players[i].displayName==name){
return b.players[i].realName
}
}
return "Geometrical Dominator"
if (data.data[i].player && data.data[i].player.name !== undefined) {
buffer2[uuid] = { realName: data.data[i].player.name, displayName: parse(parse1204(data.data[i].displayName))[1] }
} else if (data.data[i].name !== undefined) {
buffer2[uuid] = { realName: data.data[i].name, displayName: parse(parse1204(data.data[i].displayName))[1] }
} else if (data.data[i].displayName !== undefined) {
buffer2[uuid] = { displayName: parse(parse1204(data.data[i].displayName))[1] }
}
}
for (const uuid in buffer2) {
if (!b.players[uuid]) b.players[uuid] = { displayName: '', realName: '' }
if (buffer2[uuid].displayName) b.players[uuid].displayName = buffer2[uuid].displayName
if (buffer2[uuid].realName) b.players[uuid].realName = buffer2[uuid].realName
}
})
b.findUUID = (name) => {
for (const i in b.players) {
if (b.players[i].realName === name) {
return i
}
}
return '00000000-0000-0000-0000-000000000000'
}
}
b.findRealName = (name) => {
for (const i in b.players) {
if (b.players[i].displayName === name) {
return b.players[i].realName
}
}
return 'Geometrical Dominator'
}
}
}

View file

@ -1,18 +1,17 @@
const index = require('../index.js')
module.exports={
load:()=>{
},
loadBot:(b)=>{
b._client.on("end",()=>{
b.info("bot "+b.id+" disconnected");
for(const i in b.interval){
clearInterval(b.interval[i])
}
setTimeout(()=>{
b.info("Re-connecting bot "+b.id)
const b_id = b.id;
index.createBot(b.host,b.id);
},5000)
})
}
module.exports = {
load: () => {
},
loadBot: (b) => {
b._client.on('end', () => {
b.info('bot ' + b.id + ' disconnected')
for (const i in b.interval) {
clearInterval(b.interval[i])
}
setTimeout(() => {
b.info('Re-connecting bot ' + b.id)
index.createBot(b.host, b.id)
}, 5000)
})
}
}

View file

@ -1,34 +1,34 @@
class SCTask{
constructor (failTask,chatCommand,startFailed=false){
/*
class SCTask {
constructor (failTask, chatCommand, startFailed = false) {
/*
* failed: Whether to run this task
* failTask: Command to run when failed is true
* chatCommand: Whether to run failTask in chat rather than in command block
*/
this.failed=startFailed;
this.failTask=failTask;
this.chatCommand=chatCommand;
}
this.failed = startFailed
this.failTask = failTask
this.chatCommand = chatCommand
}
}
module.exports={
load:()=>{
module.exports = {
load: () => {
},
loadBot:(b)=>{
b.sc_tasks={};
b.interval.sc=setInterval(()=>{
for(const i in b.sc_tasks){
if(b.sc_tasks[i].failed){
if(b.sc_tasks[i].chatCommand){
b.chat(b.sc_tasks[i].failTask)
} else {
b.ccq.push(b.sc_tasks[i].failTask) //Does not automatically reset
}
}
}
},1000)
b.add_sc_task=(name,failTask,chatCommand,startFailed)=>{
b.sc_tasks[name] = new SCTask(failTask,chatCommand,startFailed);
},
loadBot: (b) => {
b.sc_tasks = {}
b.interval.sc = setInterval(() => {
for (const i in b.sc_tasks) {
if (b.sc_tasks[i].failed) {
if (b.sc_tasks[i].chatCommand) {
b.chat(b.sc_tasks[i].failTask)
} else {
b.ccq.push(b.sc_tasks[i].failTask) // Does not automatically reset
}
}
}
}, 1000)
b.add_sc_task = (name, failTask, chatCommand, startFailed) => {
b.sc_tasks[name] = new SCTask(failTask, chatCommand, startFailed)
}
}
}

View file

@ -1,16 +1,15 @@
module.exports = {
load: () => {
module.exports={
load:()=>{
},
loadBot:(b)=>{
b.add_sc_task("cspy","/cspy on", true, true)
b.on('plainchat', (msg) => {
if (msg == "Successfully disabled CommandSpy") {
b.sc_tasks["cspy"].failed = 1
} else if (msg == "Successfully enabled CommandSpy") {
b.sc_tasks["cspy"].failed = 0
}
})
}
},
loadBot: (b) => {
b.add_sc_task('cspy', '/cspy on', true, true)
b.on('plainchat', (msg) => {
if (msg === 'Successfully disabled CommandSpy') {
b.sc_tasks.cspy.failed = 1
} else if (msg === 'Successfully enabled CommandSpy') {
b.sc_tasks.cspy.failed = 0
}
})
}
}

View file

@ -1,16 +1,15 @@
module.exports = {
load: () => {
module.exports={
load:()=>{
},
loadBot:(b)=>{
b.add_sc_task("gamemode","/minecraft:gamemode creative", true)
b._client.on('game_state_change', (p) => {
if (p.reason == 3 && p.gameMode != 1) {
b.sc_tasks["gamemode"].failed = 1
} else if (p.reason == 3 && p.gameMode == 1) {
b.sc_tasks["gamemode"].failed = 0
}
})
}
},
loadBot: (b) => {
b.add_sc_task('gamemode', '/minecraft:gamemode creative', true)
b._client.on('game_state_change', (p) => {
if (p.reason === 3 && p.gameMode !== 1) {
b.sc_tasks.gamemode.failed = 1
} else if (p.reason === 3 && p.gameMode === 1) {
b.sc_tasks.gamemode.failed = 0
}
})
}
}

View file

@ -1,19 +1,18 @@
module.exports = {
load: () => {
module.exports={
load:()=>{
},
loadBot:(b)=>{
b.add_sc_task("op","/op @s[type=player]", true)
b._client.on('login', (p) => {
b.entityId = p.entityId
})
b._client.on('entity_status', (p) => {
if (p.entityId == b.entityId && p.entityStatus == 24) {
b.sc_tasks["op"].failed = 1
} else if (p.entityId == b.entityId && p.entityStatus == 28) {
b.sc_tasks["op"].failed = 0
}
})
}
},
loadBot: (b) => {
b.add_sc_task('op', '/op @s[type=player]', true)
b._client.on('login', (p) => {
b.entityId = p.entityId
})
b._client.on('entity_status', (p) => {
if (p.entityId === b.entityId && p.entityStatus === 24) {
b.sc_tasks.op.failed = 1
} else if (p.entityId === b.entityId && p.entityStatus === 28) {
b.sc_tasks.op.failed = 0
}
})
}
}

View file

@ -1,8 +1,8 @@
module.exports={
load:()=>{
module.exports = {
load: () => {
},
loadBot:(b)=>{
}
}
},
loadBot: (b) => {
}
}

View file

@ -1,25 +1,24 @@
//HOW TO WRITE CLASS JS
const parse = require("../util/chatparse.js");
const settings = require("../settings.json");
class Command{
constructor (uuid,user,nick,cmd,prefix,bot,verify,lang = settings.defaultLang){
this.send = (text,uuid)=>{bot.tellraw(uuid?uuid:"@a",text)};
this.reply = text => bot.tellraw(uuid,text);
this.uuid = uuid;
this.username = user;
this.nickname = nick;
this.command = cmd;
this.prefix = prefix;
this.bot = bot;
this.type = 'minecraft';
this.index = bot.id;
this.args = cmd.split(' ').slice(1);
this.verify = verify;
this.host = bot.host.host;
this.port = bot.host.port;
this.lang = lang;
this.colors = settings.colors;
}
// HOW TO WRITE CLASS JS
const settings = require('../settings.json')
class Command {
constructor (uuid, user, nick, cmd, prefix, bot, verify, lang = settings.defaultLang) {
this.send = (text, uuid) => { bot.tellraw(uuid || '@a', text) }
this.reply = text => bot.tellraw(uuid, text)
this.uuid = uuid
this.username = user
this.nickname = nick
this.command = cmd
this.prefix = prefix
this.bot = bot
this.type = 'minecraft'
this.index = bot.id
this.args = cmd.split(' ').slice(1)
this.verify = verify
this.host = bot.host.host
this.port = bot.host.port
this.lang = lang
this.colors = settings.colors
}
}
module.exports = Command;
module.exports = Command

View file

@ -1,58 +1,60 @@
//HOW TO WRITE CLASS JS
// HOW TO WRITE CLASS JS
const index = require('../index.js')
const { cmds } = require('../plugins/command.js');
const parse = require("../util/chatparse.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
this.reply = text => process.stdout.write(parse(text)[0]+'\n');
this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console'; //hard-coded because uuid does not exist at console
this.username = 'Owner';
this.nickname = 'Console';
this.command = cmd;
this.prefix = ''; //prefix does not exist at console
this.bot = index2 >= 0 ? index.bot[index2] : {
printHelp:()=>{
let helpCmds=[];
for(const i in cmds){
//if(cmds[i].hidden) continue;
helpCmds.push(i)
}
console.log(getMessage(lang,"command.help.cmdList",[helpCmds.join(" ")]))
},
printCmdHelp:(uuid,cmd)=>{
let usage=getMessage(lang,`command.${cmd}.usage`).split("||");
let desc=getMessage(lang,`command.${cmd}.desc`);
if(cmds[cmd].usage){
usage=cmds[cmd].usage.split("||");
}
if(cmds[cmd].desc){
desc=cmds[cmd].desc;
}
for(const i in usage){
console.log(getMessage(lang,"command.help.commandUsage",[cmd,usage[i]]));
}
console.log(getMessage(lang,"command.help.commandDesc",[desc]));
const permsN=getMessage(lang,"command.help.permsNormal");
const permsT=getMessage(lang,"command.help.permsTrusted");
const permsO=getMessage(lang,"command.help.permsOwner");
const permsC=getMessage(lang,"command.help.permsConsole");
const rPerms=cmds[cmd].level?cmds[cmd].level:0;
console.log(getMessage(lang,"command.help.commandPerms",[[permsN,permsT,permsO,permsC][rPerms]]));
}
}; //bot does not exist at console
this.type = 'console';
this.index = index2;
this.args = cmd.split(' ').slice(1);
this.verify = 3;
this.host = "";
this.port = "3"; // :3
this.lang = settings.defaultLang;
this.colors = settings.colors;
}
const { cmds } = require('../plugins/command.js')
const parse = require('../util/chatparse.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
this.reply = text => process.stdout.write(parse(text)[0] + '\n')
this.uuid = 'dde5a2a6-ebdd-4bbb-8eac-f75b10c10446_console' // hard-coded because uuid does not exist at console
this.username = 'Owner'
this.nickname = 'Console'
this.command = cmd
this.prefix = '' // prefix does not exist at console
this.bot = index2 >= 0
? index.bot[index2]
: {
printHelp: () => {
const helpCmds = []
for (const i in cmds) {
// if(cmds[i].hidden) continue;
helpCmds.push(i)
}
console.log(getMessage(lang, 'command.help.cmdList', [helpCmds.join(' ')]))
},
printCmdHelp: (uuid, cmd) => {
let usage = getMessage(lang, `command.${cmd}.usage`).split('||')
let desc = getMessage(lang, `command.${cmd}.desc`)
if (cmds[cmd].usage) {
usage = cmds[cmd].usage.split('||')
}
if (cmds[cmd].desc) {
desc = cmds[cmd].desc
}
for (const i in usage) {
console.log(getMessage(lang, 'command.help.commandUsage', [cmd, usage[i]]))
}
console.log(getMessage(lang, 'command.help.commandDesc', [desc]))
const permsN = getMessage(lang, 'command.help.permsNormal')
const permsT = getMessage(lang, 'command.help.permsTrusted')
const permsO = getMessage(lang, 'command.help.permsOwner')
const permsC = getMessage(lang, 'command.help.permsConsole')
const rPerms = cmds[cmd].level ? cmds[cmd].level : 0
console.log(getMessage(lang, 'command.help.commandPerms', [[permsN, permsT, permsO, permsC][rPerms]]))
}
} // bot does not exist at console
this.type = 'console'
this.index = index2
this.args = cmd.split(' ').slice(1)
this.verify = 3
this.host = ''
this.port = '3' // :3
this.lang = settings.defaultLang
this.colors = settings.colors
}
}
module.exports = ConsoleCommand;
module.exports = ConsoleCommand

View file

@ -1,133 +1,133 @@
const _lang = require("minecraft-data")("1.20.2").language;
let lang=Object.create(null); //Without constructor function
for(const i in _lang){
lang[i]=_lang[i];
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]
}
const consoleColors={
"dark_red":"\x1B[0m\x1B[38;2;170;0;0m",
"red":"\x1B[0m\x1B[38;2;255;85;85m",
"dark_green":"\x1B[0m\x1B[38;2;0;170;0m",
"green":"\x1B[0m\x1B[38;2;85;255;85m",
"gold":"\x1B[0m\x1B[38;2;255;170;0m",
"yellow":"\x1B[0m\x1B[38;2;255;255;85m",
"dark_blue":"\x1B[0m\x1B[38;2;0;0;170m",
"blue":"\x1B[0m\x1B[38;2;85;85;255m",
"dark_purple":"\x1B[0m\x1B[38;2;170;0;170m",
"light_purple":"\x1B[0m\x1B[38;2;255;85;255m",
"dark_aqua":"\x1B[0m\x1B[38;2;0;170;170m",
"aqua":"\x1B[0m\x1B[38;2;85;255;255m",
"black":"\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m",
"gray":"\x1B[0m\x1B[38;2;170;170;170m",
"dark_gray":"\x1B[0m\x1B[38;2;85;85;85m",
"white":"\x1B[0m\x1B[38;2;255;255;255m",
"reset":"\x1B[0m\x1B[38;2;255;255;255m"
const consoleColors = {
dark_red: '\x1B[0m\x1B[38;2;170;0;0m',
red: '\x1B[0m\x1B[38;2;255;85;85m',
dark_green: '\x1B[0m\x1B[38;2;0;170;0m',
green: '\x1B[0m\x1B[38;2;85;255;85m',
gold: '\x1B[0m\x1B[38;2;255;170;0m',
yellow: '\x1B[0m\x1B[38;2;255;255;85m',
dark_blue: '\x1B[0m\x1B[38;2;0;0;170m',
blue: '\x1B[0m\x1B[38;2;85;85;255m',
dark_purple: '\x1B[0m\x1B[38;2;170;0;170m',
light_purple: '\x1B[0m\x1B[38;2;255;85;255m',
dark_aqua: '\x1B[0m\x1B[38;2;0;170;170m',
aqua: '\x1B[0m\x1B[38;2;85;255;255m',
black: '\x1B[0m\x1B[48;2;220;220;220m\x1B[38;2;0;0;0m',
gray: '\x1B[0m\x1B[38;2;170;170;170m',
dark_gray: '\x1B[0m\x1B[38;2;85;85;85m',
white: '\x1B[0m\x1B[38;2;255;255;255m',
reset: '\x1B[0m\x1B[38;2;255;255;255m'
}
const hexColorParser=(color)=>{
let out="\x1B[0m";
const redChannel=Number("0x"+color.slice(1,3));
const greenChannel=Number("0x"+color.slice(3,5));
const blueChannel=Number("0x"+color.slice(5,7));
if(redChannel < 96 && greenChannel < 96 && blueChannel < 96){
out+="\x1B[48;2;220;220;220m";
}
return out+`\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m`
const hexColorParser = (color) => {
let out = '\x1B[0m'
const redChannel = Number('0x' + color.slice(1, 3))
const greenChannel = Number('0x' + color.slice(3, 5))
const blueChannel = Number('0x' + color.slice(5, 7))
if (redChannel < 96 && greenChannel < 96 && blueChannel < 96) {
out += '\x1B[48;2;220;220;220m'
}
return out + `\x1B[38;2;${redChannel};${greenChannel};${blueChannel}m`
}
const processColor=(col,rcol)=>{
let out=["",""]
if(col=="reset"){
out[0]=rcol[0]
} else if (col.startsWith("#")){
out[0]=hexColorParser(col);
const processColor = (col, rcol) => {
const out = ['', '']
if (col === 'reset') {
out[0] = rcol[0]
} else if (col.startsWith('#')) {
out[0] = hexColorParser(col)
} else {
out[0] = consoleColors[col]
}
return out
}
const parse = function (_data, l = 0, resetColor = [consoleColors.reset]) {
if (l >= 12) {
return ['', '', '']
}
let data
if (typeof _data === 'string') {
data = { text: _data, color: 'reset' }
} else if (typeof _data === 'number') {
data = { text: _data + '', color: 'reset' }
} else {
data = _data
}
let nkt = false
const out = ['', '', ''] // console plain minecraft
if (data['']) {
data.text = data['']
nkt = true
}
if (data.color) {
if (data.color === 'reset') {
out[0] += resetColor[0]
} else if (data.color.startsWith('#')) {
out[0] += hexColorParser(data.color)
} else {
out[0]=consoleColors[col];
out[0] += consoleColors[data.color]
}
return out;
} else {
out[0] += resetColor[0]
}
if (data.text) {
let _text = data.text
if (typeof _text === 'number') {
_text = _text.toString()
}
if (nkt) {
out[0] += resetColor[0]
out[2] += resetColor[1]
}
out[0] += _text.replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes and [SO] from console format
out[1] += _text
out[2] += _text
}
if (data.translate) {
let trans = data.translate.replace(/%%/g, '\ue123').replaceAll('\x1b', '').replaceAll('\x0e', '') // Remove escape codes from console format
let trans2 = data.translate.replace(/%%/g, '\ue123')
let trans3 = data.translate.replace(/%%/g, '\ue123')
if (lang[trans] !== undefined) {
trans = lang[trans].replace(/%%/g, '\ue123')
trans2 = lang[trans2].replace(/%%/g, '\ue123')
trans3 = lang[trans3].replace(/%%/g, '\ue123')
}
for (const i in data.with) {
const j2 = parse(data.with[i], l + 1, data.color ? processColor(data.color, resetColor) : resetColor)
trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans = trans.replaceAll(`%${+i + 1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans2 = trans2.replaceAll(`%${+i + 1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans3 = trans3.replaceAll(`%${+i + 1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
}
out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
}
if (data.extra) {
for (const i in data.extra) {
const parsed = parse(data.extra[i], l, data.color ? processColor(data.color, resetColor) : resetColor)
out[0] += parsed[0]
out[1] += parsed[1]
out[2] += parsed[2]
}
}
out[0] += resetColor[0]
return out
}
const parse=function(_data, l = 0, resetColor = [consoleColors.reset]){
if (l >= 12) {
return ['', '', '']
}
let data;
if(typeof _data == "string"){
data={text:_data, color: "reset"}
} else if(typeof _data == "number"){
data={text:_data+"", color: "reset"}
} else {
data=_data;
}
let nkt=false;
const out=["","",""]; //console plain minecraft
if(data[""]){
data.text=data[""];
nkt=true;
}
if(data.color){
if(data.color=="reset"){
out[0]+=resetColor[0]
} else if (data.color.startsWith("#")){
out[0]+=hexColorParser(data.color);
} else {
out[0]+=consoleColors[data.color];
}
} else {
out[0]+=resetColor[0]
}
if(data.text){
let _text=data.text;
if(typeof _text=="number"){
_text=_text.toString()
}
if(nkt){
out[0]+=resetColor[0];
out[2]+=resetColor[1];
}
out[0]+=_text.replace(/\u001b/g,"").replace(/\u000e/g,""); //Remove escape codes and [SO] from console format
out[1]+=_text;
out[2]+=_text;
}
if (data.translate) {
let trans = data.translate.replace(/%%/g, '\ue123').replace(/\u001b/g,""); //Remove escape codes from console format
let trans2 = data.translate.replace(/%%/g, '\ue123')
let trans3 = data.translate.replace(/%%/g, '\ue123')
if (lang[trans] !== undefined) {
trans = lang[trans].replace(/%%/g, '\ue123')
trans2 = lang[trans2].replace(/%%/g, '\ue123')
trans3 = lang[trans3].replace(/%%/g, '\ue123')
}
for (const i in data.with) {
const j2 = parse(data.with[i], l + 1, data.color?processColor(data.color,resetColor):resetColor)
trans = trans.replace(/%s/, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans2 = trans2.replace(/%s/, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans3 = trans3.replace(/%s/, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans = trans.replaceAll(`%${+i+1}$s`, j2[0].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans2 = trans2.replaceAll(`%${+i+1}$s`, j2[1].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
trans3 = trans3.replaceAll(`%${+i+1}$s`, j2[2].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
}
out[0] += trans.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
out[1] += trans2.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
out[2] += trans3.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
}
if(data.extra){
for(const i in data.extra){
parsed=parse(data.extra[i], l, data.color?processColor(data.color,resetColor):resetColor)
out[0]+=parsed[0];
out[1]+=parsed[1];
out[2]+=parsed[2];
}
}
out[0]+=resetColor[0];
return out;
}
const parse2=function(_data, l, resetColor){
try{
return parse(_data)
} catch(e){
console.error(e)
return [
"\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: "+JSON.stringify(_data),
"An error occured while parsing a message. See console for more information. JSON that caused the error: "+JSON.stringify(_data),
"§cAn error occured while parsing a message. See console for more information. JSON that caused the error: "+JSON.stringify(_data)
]
}
const parse2 = function (_data, l, resetColor) {
try {
return parse(_data)
} catch (e) {
console.error(e)
return [
'\x1B[0m\x1B[38;2;255;85;85mAn error occured while parsing a message. See console for more information.\nJSON that caused the error: ' + JSON.stringify(_data),
'An error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data),
'§cAn error occured while parsing a message. See console for more information. JSON that caused the error: ' + JSON.stringify(_data)
]
}
}
module.exports = parse2

View file

@ -1,11 +1,11 @@
const {processNbtMessage} = require("prismarine-chat");
const parse=function(data){
if(typeof data.type=="string"){
return JSON.parse(processNbtMessage(data));
} else if(typeof data=="string"){
return JSON.parse(data);
} else {
return data;
}
const { processNbtMessage } = require('prismarine-chat')
const parse = function (data) {
if (typeof data.type === 'string') {
return JSON.parse(processNbtMessage(data))
} else if (typeof data === 'string') {
return JSON.parse(data)
} else {
return data
}
}
module.exports = parse

View file

@ -1,19 +1,19 @@
const crypto=require("crypto");
const settings = require("../settings.json");
const secret = require(settings.secret);
const crypto = require('crypto')
const settings = require('../settings.json')
const secret = require(settings.secret)
module.exports = function (cmd) {
const cmdWithoutHash=cmd.slice(0,cmd.length-1).join(" ");
const _dateString=Date.now().toString();
const dateString=_dateString.slice(0,_dateString.length-4);
const hashTrusted="babyboom:"+secret.keyTrusted+":"+cmdWithoutHash+":"+dateString
const hashOwner="babyboom:"+secret.keyOwner+":"+cmdWithoutHash+":"+dateString
const validhashT=crypto.createHash("sha256").update(hashTrusted).digest("hex");
const validhashO=crypto.createHash("sha256").update(hashOwner).digest("hex");
if(cmd[cmd.length-1]==validhashT){
return 1;
const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ')
const _dateString = Date.now().toString()
const dateString = _dateString.slice(0, _dateString.length - 4)
const hashTrusted = 'babyboom:' + secret.keyTrusted + ':' + cmdWithoutHash + ':' + dateString
const hashOwner = 'babyboom:' + secret.keyOwner + ':' + cmdWithoutHash + ':' + dateString
const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex')
const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex')
if (cmd[cmd.length - 1] === validhashT) {
return 1
}
if(cmd[cmd.length-1]==validhashO){
return 2;
if (cmd[cmd.length - 1] === validhashO) {
return 2
}
return 0;
return 0
}

View file

@ -1,27 +1,27 @@
const fs=require("fs")
let languages={};
const fs = require('fs')
const languages = {}
const loadplug = (botno) => {
const bpl = fs.readdirSync('util/lang')
for (const i in bpl) {
if (!bpl[i].endsWith('.json')) {
continue
}
try {
languages[bpl[i].split(".")[0]]=require(`./lang/${bpl[i]}`)
} catch (e) { console.log(e) }
if (!bpl[i].endsWith('.json')) {
continue
}
try {
languages[bpl[i].split('.')[0]] = require(`./lang/${bpl[i]}`)
} catch (e) { console.log(e) }
}
}
loadplug()
module.exports = function (l, msg, with2) {
let message=msg.replace(/%%/g, '\ue123');
let message = msg.replace(/%%/g, '\ue123')
if (languages[l][message] !== undefined) {
message = languages[l][message].replace(/%%/g, '\ue123')
} else if (languages["en-US"][message] !== undefined) {
message = languages["en-US"][message].replace(/%%/g, '\ue123')
} else if (languages['en-US'][message] !== undefined) {
message = languages['en-US'][message].replace(/%%/g, '\ue123')
}
for(i in with2){
for (const i in with2) {
message = message.replace(/%s/, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
message = message.replaceAll(`%${+i+1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
message = message.replaceAll(`%${+i + 1}$s`, with2[i].replace(/%s/g, '\ue124').replace(/\$s/g, '\ue125'))
}
return message.replace(/\ue123/g, '%').replace(/\ue124/g, '%s').replace(/\ue125/g, '$s')
}

View file

@ -1,16 +1,16 @@
const settings=require("../settings.json");
const settings = require('../settings.json')
module.exports = function (text) {
return JSON.stringify({
translate: "[%s] %s",
color: "#FFAAFF",
with:[
translate: '[%s] %s',
color: '#FFAAFF',
with: [
{
text: settings.name,
color: "light_purple"
color: 'light_purple'
},
{
text: text,
color: "white"
text,
color: 'white'
}
]
})

View file

@ -5,20 +5,20 @@ module.exports = function (time) {
const hours = Math.floor(time / 3600000) % 24
const days = Math.floor(time / 86400000) % 7
const weeks = Math.floor(time / 604800000)
if (weeks != 0) {
finalString += `${weeks} week${weeks == 1 ? '' : 's'} `
if (weeks !== 0) {
finalString += `${weeks} week${weeks === 1 ? '' : 's'} `
}
if (days != 0) {
finalString += `${days} day${days == 1 ? '' : 's'} `
if (days !== 0) {
finalString += `${days} day${days === 1 ? '' : 's'} `
}
if (hours != 0) {
finalString += `${hours} hour${hours == 1 ? '' : 's'} `
if (hours !== 0) {
finalString += `${hours} hour${hours === 1 ? '' : 's'} `
}
if (minutes != 0) {
finalString += `${minutes} minute${minutes == 1 ? '' : 's'} `
if (minutes !== 0) {
finalString += `${minutes} minute${minutes === 1 ? '' : 's'} `
}
if (seconds != 0) {
finalString += `${seconds} second${seconds == 1 ? '' : 's'} `
if (seconds !== 0) {
finalString += `${seconds} second${seconds === 1 ? '' : 's'} `
}
return finalString
}

View file

@ -1,22 +1,22 @@
const rsg=function(count){
let output="";
for(let i=0; i<count; i++){
let rng=Math.floor(Math.random()*16)+1;
if(rng==7) rng=17; //No bells
if(rng==10) rng=18; //No line feeds
if(rng==11) rng=19; //No vertical tabulations
if(rng==12) rng=20; //No form feed
if(rng==13) rng=21; //No carriage returns
if(rng==14) rng=22; //No shift out
if(rng==15) rng=23; //No shift in
output+=String.fromCharCode(rng)
const rsg = function (count) {
let output = ''
for (let i = 0; i < count; i++) {
let rng = Math.floor(Math.random() * 16) + 1
if (rng === 7) rng = 17 // No bells
if (rng === 10) rng = 18 // No line feeds
if (rng === 11) rng = 19 // No vertical tabulations
if (rng === 12) rng = 20 // No form feed
if (rng === 13) rng = 21 // No carriage returns
if (rng === 14) rng = 22 // No shift out
if (rng === 15) rng = 23 // No shift in
output += String.fromCharCode(rng)
}
return output;
return output
}
module.exports = function (legal) {
if(legal){
return Math.floor(Math.random()*1000000).toString()
if (legal) {
return Math.floor(Math.random() * 1000000).toString()
} else {
return " \xa7"+rsg(6)+" "+rsg(4)
return ' \xa7' + rsg(6) + ' ' + rsg(4)
}
}

View file

@ -1,5 +1,5 @@
module.exports = function (uuid) {
const split_uuid = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g)
const num_uuid = [+split_uuid[0] << 0, +split_uuid[1] << 0, +split_uuid[2] << 0, +split_uuid[3] << 0]
return num_uuid
const splitUUID = uuid.replace(/[^0-9a-f]/g, '').replace(/.{1,8}/g, a => { return '0x' + a }).match(/.{1,10}/g)
const numUUID = [+splitUUID[0] << 0, +splitUUID[1] << 0, +splitUUID[2] << 0, +splitUUID[3] << 0]
return numUUID
}