From 2ad15dadac4e6ce8a840dfee18f607a1413c68b6 Mon Sep 17 00:00:00 2001 From: MrGeorgen Date: Fri, 17 Apr 2020 17:10:37 +0200 Subject: [PATCH] displays custom calculated ETA --- src/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 558bc9a..559769a 100644 --- a/src/main.js +++ b/src/main.js @@ -90,11 +90,11 @@ function startQueuing() { if (!finishedQueue && config.minecraftserver.hostname === "2b2t.org") { // if the packet contains the player list, we can use it to see our place in the queue let headermessage = JSON.parse(data.header); let positioninqueue = headermessage.text.split("\n")[5].substring(25); - let ETA = headermessage.text.split("\n")[6].substring(27); webserver.queuePlace = positioninqueue; // update info on the web page - webserver.ETA = ETA; - server.motd = `Place in queue: ${positioninqueue}`; // set the MOTD because why not if (webserver.queuePlace !== "None" && lastQueuePlace !== webserver.queuePlace) { + let ETAhour = -Math.pow(positioninqueue/35.4, 2/3)+totalWaitTime; + webserver.ETA = Math.floor(ETAhour) + "h " + ETAhour%1*60 + "m"; + server.motd = `Place in queue: ${positioninqueue}`; // set the MOTD because why not activity("Pos: " + webserver.queuePlace + " ETA: " + webserver.ETA); //set the Discord Activity log("Position in Queue: " + webserver.queuePlace) if (config.notification.enabled && webserver.queuePlace <= config.notification.queuePlace && !notisend && config.discordBot && id != null) {