-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
40 lines (28 loc) · 954 Bytes
/
index.js
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
33
34
35
36
37
38
39
40
const mcdata = require('minecraft-data')
const path = require('path')
const { EventEmitter } = require('events')
const { config } = require('./lib/config')
const emitter = new EventEmitter()
module.exports = emitter
emitter.on('packet', (data, meta) => {
})
emitter.runProxy = async function (port) {
let globalVersion = '0.0.0'
async function startProxyServer () {
return new Promise(resolve => {
protocol.ping({
host: config.server.host.split(':')[0] || 'localhost',
port: +config.server.host.split(':')[1] || 25565
}, async (err, result) => {
// Only supporting PC versions right now
await createProxyServer(+config.server.proxyPort, version.minecraftVersion)
return resolve({ version: version.minecraftVersion, packets: getPackets(version.minecraftVersion) })
})
})
}
startProxyServer().then(({ error }) => {
if (error) {
console.log(error)
}
})
}