-
Notifications
You must be signed in to change notification settings - Fork 2
/
vers.go
executable file
·40 lines (34 loc) · 990 Bytes
/
vers.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
35
36
37
38
39
40
package vers
import (
"github.com/df-mc/dragonfly/server"
"github.com/sandertv/gophertunnel/minecraft"
)
// Vers is an instance for binding a multi-version Dragonfly server.
type Vers struct {
addr string
}
// New creates a new Vers instance.
func New(localAddr string) *Vers {
return &Vers{
addr: localAddr,
}
}
// Listen listens for incoming connections on the address.
func (v *Vers) Listen(conf *server.Config, name string, protocols []minecraft.Protocol, requirePacks bool) {
conf.Listeners = nil
conf.Listeners = append(conf.Listeners, func(_ server.Config) (server.Listener, error) {
l, err := minecraft.ListenConfig{
StatusProvider: minecraft.NewStatusProvider(name),
ResourcePacks: conf.Resources,
TexturePacksRequired: requirePacks,
AcceptedProtocols: protocols,
}.Listen("raknet", v.addr)
if err != nil {
return nil, err
}
conf.Log.Infof("Server running on %v.", l.Addr())
return listener{
Listener: l,
}, nil
})
}