Skip to content

Commit 800ff07

Browse files
init opts
1 parent 71c951a commit 800ff07

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

cmd/client/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func main() {
4848
panic(err)
4949
}
5050

51-
err = commandclient.Init(client, username)
51+
err = commandclient.Init(client, username, nil)
5252
if err != nil {
5353
panic(err)
5454
}

commandclient/init.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,23 @@ import (
77
"github.com/minetest-go/minetest_client/commands"
88
)
99

10-
func Init(cc *CommandClient, username string) error {
10+
type InitOpts struct {
11+
ClientInit *commands.ClientInit
12+
}
13+
14+
func Init(cc *CommandClient, username string, opts *InitOpts) error {
15+
if opts == nil {
16+
opts = &InitOpts{}
17+
}
18+
if opts.ClientInit == nil {
19+
opts.ClientInit = commands.NewClientInit(username)
20+
}
21+
1122
for o := range cc.CommandChannel() {
1223
switch o.(type) {
1324
case *commands.ServerSetPeer:
1425
time.Sleep(1 * time.Second)
15-
err := cc.SendOriginalCommand(commands.NewClientInit(username))
26+
err := cc.SendOriginalCommand(opts.ClientInit)
1627
return err
1728
}
1829
}

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ func main() {
6464
panic(err)
6565
}
6666

67-
err = commandclient.Init(client, username)
67+
err = commandclient.Init(client, username, nil)
6868
if err != nil {
6969
panic(err)
7070
}
7171

72-
err = commandclient.Login(client, username, password)
72+
enable_registration := true
73+
err = commandclient.Login(client, username, password, enable_registration)
7374
if err != nil {
7475
panic(err)
7576
}

0 commit comments

Comments
 (0)