Commit 34c2b1d2 authored by Family Friendly#0001's avatar Family Friendly#0001 💬

things

parent 69eb2777
......@@ -7,6 +7,6 @@ exports.run = (args,u,mc) => {
*/
}
exports.config = {
name: "info",
info: "tells info about this client"
name: "template____dontUSE",
info: "template command"
}
\ No newline at end of file
exports.run = (args,u,mc,e) => {
let cmds = e.commands
for(let command of cmds) {
let y = command[1].config
mc.log( `/tellraw ${u} ["",{"text":"${y.name} ","color":"gold"},{"text":"- ${y.info}"}]`)
}
}
exports.config = {
name: "help",
info: "sends help"
}
\ No newline at end of file
exports.run = (args,u,mc) => {
mc.stdin.write(`/tellraw ${u} ["",{"text":"Made by "},{"text":"Family Friendly#0001 ","color":"gold"},{"text":"ver "},{"text":"1.0.0","italic":true}]\n`)
exports.run = (args,u,mc,e) => {
mc.stdin.write(`/tellraw ${u} ["",{"text":"Made by "},{"text":"Family Friendly#0001 ","color":"gold"}]\n`)
}
exports.config = {
name: "info",
......
exports.run = (args,u,mc,e) => {
if(!e.excused.includes(u)) return mc.stdin.write(`/tellraw ${u} {"text":"you do not have access to this command..."}\n`)
e.commands.clear()
let output = require("../script/util.js").load(e.commands)
}
exports.config = {
name: "reload",
info: "reloads commands"
}
\ No newline at end of file
exports.snippet = (args) => {
return args[Math.floor(Math.random() * args.length)]
}
\ No newline at end of file
......@@ -17,11 +17,11 @@ exports.run = (args,u,mc,e) => {
}
}
}
if(!args[1]) return
if(!db.exists(args[1])) return mc.stdin.write(`/tellraw ${u} ["",{"text":"tag \\""},{"text":"${args[1]}","color":"gold"},{"text":"\\" does not exist"}]\n`)
let ddta = db.get(args[1])
let locked = false;
ddta = ddta.replace(/@u|@s|@locked/gi, (x) => {
ddta = ddta.replace(/@u|@s|@locked|@run:\w.+ /gi, (x) => {
switch(x)
{
case "@u":
......@@ -36,6 +36,15 @@ exports.run = (args,u,mc,e) => {
}
x=""
break;
default:
let m = x.match(/(?<=@run:)\w.+(?= )/gi)
try{
x = require(`./snippets/${m}`).snippet(args,u,mc,e)
} catch(err) {
mc.log(`msg ${u} §6snippet failed §r ${err}`)
}
break;
}
return x;
})
......@@ -43,6 +52,6 @@ exports.run = (args,u,mc,e) => {
mc.stdin.write(`/tellraw @a {"text":"${ddta}"}\n`)
}
exports.config = {
name: "info",
info: "tells info about this client"
name: "tag",
info: "tag commad"
}
\ No newline at end of file
......@@ -5,7 +5,6 @@ var config = ini.parse(fs.readFileSync('./script/settings.ini', 'utf-8'))
var util = require("./util.js")
var lang = require("./lang.json")
var chalk = require("chalk")
var commands = require("./commands.js")
var cmds = new Map()
......@@ -19,10 +18,17 @@ if(!lang[config.main.locale]) return console.log(`lang "${config.main.locale}" d
console.log(`${lang[config.main.locale][1]}:\n${chalk.blue.underline("MAIN:")}\n${Object.keys(config.main).map(ob=> `${chalk.underline(ob)}:${config.main[ob]}`).join("\n")}\n${chalk.blue.underline("config:")}\n${Object.keys(config.config).map(ob=> `${chalk.underline(ob)}:${config.config[ob]}`).join("\n")}`)
console.log(chalk.green.underline(lang[config.main.locale][0]))
console.time(`startup`)
util.updates(config)
util.updates(config)
//start child proccess
var mc = spawn("java",['-jar', '-Xms1G','-Xmx1G', '-Dfile.encoding=utf8', config.main.path, config.config.gui ? null:"nogui"])
mc.log = (text) => {
mc.stdin.write(`${text}\n`)
}
let userinf = {};
let done = false;
......@@ -44,6 +50,7 @@ setInterval(() => {
mc.stdout.on("data", stdout => {
//buffer => string
let data = stdout.toString();
if(config.main.debug) console.log(data)
//if data includes "Done" we will set the done bool to true
if(data.includes("Done")) {
util.load(cmds)
......@@ -55,7 +62,6 @@ if(data.includes("Done")) {
//this code is spaghetti, clean please
if(done) {
if(config.main.debug) console.log(data)
//get the user
let user = data.match(/(?<=\<).+(?=\>)/)
if(!user || !user[0]) return
......@@ -71,14 +77,15 @@ if(done) {
let wrdarr = chat[0].toLowerCase().split(" ")
if(chat[0].startsWith(config.config.prefix)) {
let com = wrdarr[0].slice(config.config.prefix.length).trim().split(/ +/g);
com = com[0]
if(!cmds.has(com)) return mc.stdin.write(`/tellraw ${user[0]} ["",{"text":"command \\""},{"text":"${com}","color":"yellow"},{"text":"\\" does not exist"}]\n`)
else {
try{
let _run = cmds.get(com)
_run.run(wrdarr,user[0],mc,{uin:userinf,excused:config.config.excused},commands)
_run.run(wrdarr,user[0],mc,{commands:cmds,uin:userinf,excused:config.config.excused})
} catch (err) {
let str64 = Buffer.from(String(Math.floor(Math.random() * 2000))).toString("base64")
fs.writeFileSync(`./errorLogs/${str64}.txt`, err)
fs.writeFileSync(`./errorLogs/${str64}.txt`, err.stack)
mc.stdin.write(`/tellraw @a ["",{"text":"command \\""},{"text":"${com}","color":"gold"},{"text":"\\" ran into an error. File of the event is saved with trace ID ${str64}"}]\n`)
}
......
version=4
version=5
[main]
; swe/en
locale=en
; path to mc server .jar
path=E:\kodning\mcUtil\server\server.jar
;enbales debug features
debug=true
debug=false
; time between reload of this ini file
reloadTime=50000
; auto update
......@@ -24,7 +24,7 @@ gui=false
blockedwords[]=
;array of excused users
excused[]=
excused[]=famfriendly
;mod config
;max inf per session for user
......
......@@ -2,13 +2,15 @@ const https = require('https');
const chalk = require("chalk")
const { exec } = require('child_process');
const fs = require("fs")
const readline = require('readline');
exports.load = (_map) => {
let _loadedinf = []
fs.readdirSync("./commands").map(f => {
try {
//require file
let fr = require(`./commands/${f}`)
if(f === "snippets") return
let fr = require(`../commands/${f}`)
_loadedinf.push({
name: fr.config.name,
info: fr.config.info,
......@@ -48,19 +50,19 @@ exports.updates = (conf) => {
console.log(`- ${data[0].release.description}`)
if(conf.main.aupdate) {
console.log(`auto update: ${chalk.green("true : updating")}`)
exec('git fetch https://gitlab.com/familyfriendly/mcutil.git && git reset --hard origin/master && git clean -f -d',(error,stdout,stderr) => {
console.log(`
error: ${error ? "true":"false"}
${error ? `- ${error}`:""}
stdout: ${stdout ? "true":"false"}
${stdout ? `- ${stdout}`:""}
stderr: ${stderr ? "true":"false"}
${stderr ? `- ${stderr}`:""}
`)
});
loadUpdate()
} else {
console.log(`auto update: ${chalk.red("false : not updating")}`)
console.log(`auto update: ${chalk.red("false : asking")}`)
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('do you want to update? (y/n)', (answer) => {
if(answer.toLocaleLowerCase() === "y") loadUpdate()
else console.log("ok :(")
rl.close();
});
}
}
......@@ -74,3 +76,16 @@ exports.updates = (conf) => {
}
function loadUpdate() {
exec('git reset --hard && git pull https://gitlab.com/familyfriendly/mcutil.git',(error,stdout,stderr) => {
console.log(`
error: ${error ? "true":"false"}
${error ? `- ${error}`:""}
stdout: ${stdout ? "true":"false"}
${stdout ? `- ${stdout}`:""}
stderr: ${stderr ? "true":"false"}
${stderr ? `- ${stderr}`:""}
`)
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment