-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
32 lines (30 loc) · 861 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import bedrock, { Player } from "bedrock-protocol"
import axios from "axios"
import conf from "./main.conf"
const server = bedrock.createServer({
host: conf.bedrock.ip,
port: conf.bedrock.port,
version: conf.bedrock.version,
motd: {
motd: conf.strings.motd,
levelName: conf.strings.levelname
}
})
server.on('connect', (client: Player) => {
client.on('join', () => {
const XUID = client.profile?.xuid
if (!XUID) {
client.disconnect(conf.strings.getFailed)
console.log(`Can't get player XUID`)
return
}
const code = '0'
axios.get(conf.url(code, XUID)).then((res) => {
if (res.status == 200)
return client.disconnect(conf.strings.success(code))
else return client.disconnect(conf.strings.routeFailed + conf.strings.report)
}).catch(() => {
client.disconnect(conf.strings.routeFailed + conf.strings.report)
})
})
})