update cmd gives better output
This commit is contained in:
@ -11,14 +11,14 @@
|
|||||||
"logging": true, // log errors and queue place
|
"logging": true, // log errors and queue place
|
||||||
"reconnect": {
|
"reconnect": {
|
||||||
"onError": true, // reconnect on error or if 2b2t kicks you
|
"onError": true, // reconnect on error or if 2b2t kicks you
|
||||||
"notConnectedQueueEnd": true // restart the queue if you are not connect at the end of it
|
"notConnectedQueueEnd": false // restart the queue if you are not connect at the end of it
|
||||||
},
|
},
|
||||||
"minecraftserver": { // the server you want to connect. Make not much sense to change it, was just added for development purpose
|
"minecraftserver": { // the server you want to connect. Make not much sense to change it, was just added for development purpose
|
||||||
"hostname": "localhost",
|
"hostname": "2b2t.org",
|
||||||
"port": 25565,
|
"port": 25565,
|
||||||
"renderDistance": 8,
|
"renderDistance": 8,
|
||||||
"version": "1.12.2",
|
"version": "1.12.2",
|
||||||
"onlinemode": false, // chunk caching does not work correctly if set to false
|
"onlinemode": true, // chunk caching does not work correctly if set to false
|
||||||
"username": "lol" // the username to use if onlinemode is false
|
"username": "lol" // the username to use if onlinemode is false
|
||||||
},
|
},
|
||||||
"notification": { // sends a message via discord if the place in the queue reaches the specified number
|
"notification": { // sends a message via discord if the place in the queue reaches the specified number
|
||||||
|
|||||||
130
src/main.js
130
src/main.js
@ -208,7 +208,7 @@ function join() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on('login', (newProxyClient) => { // handle login
|
server.on('login', (newProxyClient) => { // handle login
|
||||||
setTimeout(sendChunks, 50)
|
setTimeout(sendChunks, 1000)
|
||||||
if (config.antiAntiAFK) clearInterval(antiAntiAFk);
|
if (config.antiAntiAFK) clearInterval(antiAntiAFk);
|
||||||
newProxyClient.write('login', loginpacket);
|
newProxyClient.write('login', loginpacket);
|
||||||
newProxyClient.write('position', {
|
newProxyClient.write('position', {
|
||||||
@ -237,7 +237,6 @@ function join() {
|
|||||||
chunkPos.lz = chunkPos.z;
|
chunkPos.lz = chunkPos.z;
|
||||||
}
|
}
|
||||||
filterPacketAndSend(data, meta, client);
|
filterPacketAndSend(data, meta, client);
|
||||||
//console.log("meta: " + JSON.stringify(meta) + "\ndata: " + JSON.stringify(data))
|
|
||||||
});
|
});
|
||||||
newProxyClient.on("end", () => {
|
newProxyClient.on("end", () => {
|
||||||
antiAntiAfkmsg();
|
antiAntiAfkmsg();
|
||||||
@ -254,26 +253,31 @@ function sendChunks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function log(logmsg) {
|
function log(logmsg) {
|
||||||
if (config.logging) fs.appendFile('../2smart2wait.log', DateTime.local().toLocaleString({
|
if (config.logging) {
|
||||||
hour: '2-digit',
|
fs.appendFile('../2smart2wait.log', DateTime.local().toLocaleString({
|
||||||
minute: '2-digit',
|
hour: '2-digit',
|
||||||
hour12: false
|
minute: '2-digit',
|
||||||
}) + " " + logmsg + "\n", err => {
|
hour12: false
|
||||||
if (err) console.error(err)
|
}) + " " + logmsg + "\n", err => {
|
||||||
})
|
if (err) console.error(err)
|
||||||
|
})
|
||||||
|
console.log(logmsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function reconnect() {
|
function reconnect() {
|
||||||
doing = "reconnect"
|
doing = "reconnect"
|
||||||
reconnectinterval = setInterval(function () {
|
reconnectLoop();
|
||||||
ping(config.minecraftserver.hostname, config.minecraftserver.port)
|
}
|
||||||
.then((response) => {
|
|
||||||
if (doing === "reconnect") startQueuing();
|
function reconnectLoop() {
|
||||||
clearInterval(reconnectinterval);
|
ping(config.minecraftserver.hostname, config.minecraftserver.port)
|
||||||
})
|
.then((response) => {
|
||||||
.catch((error) => {
|
startQueuing();
|
||||||
});
|
})
|
||||||
}, 500)
|
.catch((error) => {
|
||||||
|
setTimeout(reconnectLoop, 3000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//function to filter out some packets that would make us disconnect otherwise.
|
//function to filter out some packets that would make us disconnect otherwise.
|
||||||
@ -331,54 +335,83 @@ function userInput(cmd, DiscordOrigin, discordMsg) {
|
|||||||
else console.log("Queue is starting up.")
|
else console.log("Queue is starting up.")
|
||||||
break;
|
break;
|
||||||
case "update":
|
case "update":
|
||||||
if (DiscordOrigin) discordMsg.channel.send({
|
switch (doing) {
|
||||||
embed: {
|
case "queue":
|
||||||
color: 3447003,
|
if (DiscordOrigin) discordMsg.channel.send({
|
||||||
author: {
|
embed: {
|
||||||
name: dc.user.username,
|
color: 3447003,
|
||||||
icon_url: dc.user.avatarURL
|
author: {
|
||||||
},
|
name: dc.user.username,
|
||||||
title: "2bored2wait discord bridge",
|
icon_url: dc.user.avatarURL
|
||||||
description: "Start and stop the queue from discord!",
|
},
|
||||||
fields: [{
|
title: "2bored2wait discord bridge",
|
||||||
name: "Position",
|
description: "Start and stop the queue from discord!",
|
||||||
value: `You are in position **${webserver.queuePlace}**.`
|
fields: [{
|
||||||
},
|
name: "Position",
|
||||||
{
|
value: `You are in position **${webserver.queuePlace}**.`
|
||||||
name: "ETA",
|
},
|
||||||
value: `Estimated time until login: **${webserver.ETA}**`
|
{
|
||||||
|
name: "ETA",
|
||||||
|
value: `Estimated time until login: **${webserver.ETA}**`
|
||||||
|
}
|
||||||
|
],
|
||||||
|
timestamp: new Date(),
|
||||||
|
footer: {
|
||||||
|
icon_url: dc.user.avatarURL,
|
||||||
|
text: "Author: Surprisejedi"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
});
|
||||||
timestamp: new Date(),
|
else console.log("Position: " + webserver.queuePlace + " Estimated time until login: " + webserver.ETA);
|
||||||
footer: {
|
break;
|
||||||
icon_url: dc.user.avatarURL,
|
case "timedStart":
|
||||||
text: "Author: Surprisejedi"
|
let timerMsg = "Timer is set to " + starttimestring;
|
||||||
}
|
if (DiscordOrigin) sendDiscordMsg(discordMsg.channel, "Timer", timerMsg);
|
||||||
}
|
else console.log(timerMsg);
|
||||||
});
|
break;
|
||||||
else console.log("Position: " + webserver.queuePlace + " Estimated time until login: " + webserver.ETA);
|
case "reconnect":
|
||||||
|
let reconnectMsg = "2bt is currently offline. Trying to reconnect";
|
||||||
|
if (DiscordOrigin) sendDiscordMsg("Reconnecting", reconnectMsg);
|
||||||
|
else console.log(reconnectMsg);
|
||||||
|
break;
|
||||||
|
case "auth":
|
||||||
|
let authMsg = "Authentication";
|
||||||
|
if (DiscordOrigin) sendDiscordMsg(authMsg, authMsg);
|
||||||
|
else console.log(authMsg);
|
||||||
|
break;
|
||||||
|
case "calcTime":
|
||||||
|
let calcMsg = "Calculating the time, so you can paly at " + starttimestring
|
||||||
|
if (DiscordOrigin) sendDiscordMsg("calculating time", calcMsg);
|
||||||
|
console.log(calcMsg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "stop":
|
case "stop":
|
||||||
switch (doing) {
|
switch (doing) {
|
||||||
case "queue":
|
case "queue":
|
||||||
stop();
|
stop();
|
||||||
stopMsg(DiscordOrigin, discordMsg.channel, "Queue");
|
if (DiscordOrigin) stopMsg(DiscordOrigin, discordMsg.channel, "Queue");
|
||||||
|
else console.log("The queue is stopped");
|
||||||
break;
|
break;
|
||||||
case "timedStart":
|
case "timedStart":
|
||||||
clearTimeout(timedStart);
|
clearTimeout(timedStart);
|
||||||
stopMsg(DiscordOrigin, discordMsg.channel, "Timer");
|
if (DiscordOrigin) stopMsg(DiscordOrigin, discordMsg.channel, "Timer");
|
||||||
|
else console.log("The timer is stopped");
|
||||||
break;
|
break;
|
||||||
case "reconnect":
|
case "reconnect":
|
||||||
clearInterval(reconnectinterval);
|
clearInterval(reconnectinterval);
|
||||||
stopMsg(DiscordOrigin, discordMsg.channel, "Reconnecting");
|
if (DiscordOrigin) stopMsg(DiscordOrigin, discordMsg.channel, "Reconnecting");
|
||||||
|
else console.log("Reconnecting is stoppd");
|
||||||
break;
|
break;
|
||||||
case "auth":
|
case "auth":
|
||||||
clearInterval(authInterval);
|
clearInterval(authInterval);
|
||||||
stopMsg(DiscordOrigin, discordMsg.channel, "Authentication");
|
if (DiscordOrigin) stopMsg(DiscordOrigin, discordMsg.channel, "Authentication");
|
||||||
|
else console.log("Authentication is stopped");
|
||||||
break;
|
break;
|
||||||
case "calcTime":
|
case "calcTime":
|
||||||
clearInterval(calcInterval);
|
clearInterval(calcInterval);
|
||||||
stopMsg(DiscordOrigin, discordMsg.channel, "Time calculation");
|
if (DiscordOrigin) stopMsg(DiscordOrigin, discordMsg.channel, "Time calculation");
|
||||||
|
else console.log("Time calculation is stopped");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -396,6 +429,7 @@ function userInput(cmd, DiscordOrigin, discordMsg) {
|
|||||||
let output = "The perfect time to start the will be calculated, so you play at " + starttimestring;
|
let output = "The perfect time to start the will be calculated, so you play at " + starttimestring;
|
||||||
if (DiscordOrigin) sendDiscordMsg(discordMsg.channel, "time calculator", output);
|
if (DiscordOrigin) sendDiscordMsg(discordMsg.channel, "time calculator", output);
|
||||||
else console.log(output);
|
else console.log(output);
|
||||||
|
activity("You can play at " + starttimestring);
|
||||||
} else if (DiscordOrigin) discordMsg.channel.send("Error: Unknown command");
|
} else if (DiscordOrigin) discordMsg.channel.send("Error: Unknown command");
|
||||||
else console.error("Unknown command")
|
else console.error("Unknown command")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user