add initial config
This commit is contained in:
parent
2970a8781a
commit
b8db1b7c94
3 changed files with 24 additions and 9 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
node_modules
|
||||
data.sqlite
|
||||
config.json
|
||||
|
|
11
config.example.json
Normal file
11
config.example.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"minecraft": {
|
||||
"host": "localhost",
|
||||
"port": 25565,
|
||||
"version": "1.21.4",
|
||||
|
||||
"auth": "microsoft",
|
||||
"username": "Notch"
|
||||
},
|
||||
"database": "./data.sqlite"
|
||||
}
|
21
src/main.js
21
src/main.js
|
@ -1,5 +1,6 @@
|
|||
import mcProtocol from "minecraft-protocol"
|
||||
import sqlite from "node:sqlite"
|
||||
import fs from "node:fs/promises"
|
||||
import migrateDB from "./migrations.js"
|
||||
import PlayerTracker from "./player-tracker.js"
|
||||
|
||||
|
@ -29,7 +30,16 @@ console.log(` ___) | |_) |__) | |_| |_) | (_) | |_ `)
|
|||
console.log(`|____/|_.__/____/ \\__|____/ \\___/ \\__|`)
|
||||
console.log(` `)
|
||||
|
||||
const db = new sqlite.DatabaseSync("./data.sqlite")
|
||||
let config
|
||||
try {
|
||||
const raw = await fs.readFile("./config.json", "utf-8")
|
||||
config = JSON.parse(raw)
|
||||
} catch (e) {
|
||||
console.error(`Failed to read config: ${e}`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const db = new sqlite.DatabaseSync(config.database)
|
||||
migrateDB(db)
|
||||
|
||||
const reconnectDelay = 10_000
|
||||
|
@ -46,14 +56,7 @@ function newClient() {
|
|||
console.log("Client connecting")
|
||||
|
||||
// Client
|
||||
const client = mcProtocol.createClient({
|
||||
host: "3b3tnohax.apexmc.co",
|
||||
port: 25588,
|
||||
version: "1.21.4",
|
||||
|
||||
auth: "microsoft",
|
||||
username: "1e98",
|
||||
})
|
||||
const client = mcProtocol.createClient(config.minecraft)
|
||||
|
||||
client.addListener("connect", () => {
|
||||
console.log("Client connected")
|
||||
|
|
Loading…
Add table
Reference in a new issue