forked from cooldogedev/spectrum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
34 lines (28 loc) · 728 Bytes
/
api.go
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
package main
import (
"log/slog"
"github.com/cooldogedev/spectrum"
"github.com/cooldogedev/spectrum/api"
"github.com/cooldogedev/spectrum/server"
"github.com/cooldogedev/spectrum/util"
"github.com/sandertv/gophertunnel/minecraft"
)
func main() {
logger := slog.Default()
proxy := spectrum.NewSpectrum(server.NewStaticDiscovery("127.0.0.1:19133", ""), logger, nil, nil)
if err := proxy.Listen(minecraft.ListenConfig{StatusProvider: util.NewStatusProvider("Spectrum Proxy", "Spectrum")}); err != nil {
return
}
go func() {
a := api.NewAPI(proxy.Registry(), logger, nil)
if err := a.Listen("127.0.0.1:19132"); err != nil {
return
}
for {
_ = a.Accept()
}
}()
for {
_, _ = proxy.Accept()
}
}