From b3548cfee7fab42ddf81aa5720cad8cb9fcd7d6d Mon Sep 17 00:00:00 2001 From: furo Date: Mon, 1 Nov 2021 01:05:37 +0100 Subject: [PATCH] I'm unsure what I'm doing... --- .gitignore | 2 +- libs/ddnss/handler.js | 62 ++++++++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index bb130e1..7603cfd 100644 --- a/.gitignore +++ b/.gitignore @@ -122,4 +122,4 @@ pnpm-lock.yaml *.sql* players.msgpack .env -ddnss/build \ No newline at end of file +ddnss/ \ No newline at end of file diff --git a/libs/ddnss/handler.js b/libs/ddnss/handler.js index 939efba..7f2a6ce 100644 --- a/libs/ddnss/handler.js +++ b/libs/ddnss/handler.js @@ -14,8 +14,14 @@ export async function ddnssStart() { for (const server of servers) { const connection = `${server.ip}:${server.port}` - if (!(server.num_clients > 0 && server.num_clients < (server.max_clients - 2))) - return log(`Server (essentially) full! >> ${server.ip}:${server.port} -> ${server.num_clients}/${server.max_clients} clients`) + if (!(server.num_clients > 0 && server.num_clients < (server.max_clients - 2))) { + log(`Server (essentially) full! >> ${connection} -> ${server.num_clients}/${server.max_clients} clients`) + continue + } + if(server.password) { + log(`Server is locked >> ${connection}`) + continue + } log(`Connecting to server >> ${connection}`) await scrapeServer(`${connection}`) @@ -39,36 +45,36 @@ function scrapeServer(server) { } const currentTime = Date.now() - + // TODO: Store statement once and reuse same statment. (whatever that means) for (const entry of skinData) - skinDB - .prepare(` + skinDB.prepare(` INSERT INTO "skindata" ( - timestamp, - player, - clan, - flag, - skin, - useColor, - colorBodyRaw, - colorBodyHex, - colorFeetRaw, - ColorFeetHex - ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + $timestamp, + $player, + $clan, + $flag, + $skin, + $useColor, + $colorBodyRaw, + $colorBodyHex, + $colorFeetRaw, + $ColorFeetHex + ) `) - .run( - currentTime, - entry.player, - entry.clan, - entry.flag, - entry.skindata.skin, - entry.skindata.useColor, - entry.skindata.colorBody.raw, - entry.skindata.colorBody.hex, - entry.skindata.colorFeet.raw, - entry.skindata.colorFeet.hex, - ) + .run({ + timestamp: currentTime, + player: entry.player, + clan: entry.clan, + flag: entry.flag, + skin: entry.skindata.skin, + useColor: entry.skindata.useColor, + colorBodyRaw: entry.skindata.colorBody.raw, + colorBodyHex: entry.skindata.colorBody.hex, + colorFeetRaw: entry.skindata.colorFeet.raw, + colorFeetHex: entry.skindata.colorFeet.hex, + }) + } catch (e) { log(`Failed to handle ${server}!`) }