forked from Brougud/inv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
63 lines (49 loc) · 1.39 KB
/
main.go
File metadata and controls
63 lines (49 loc) · 1.39 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"fmt"
"github.com/bedrock-gophers/intercept/intercept"
"github.com/bedrock-gophers/inv/inv"
"github.com/df-mc/dragonfly/server"
"github.com/df-mc/dragonfly/server/block"
"github.com/df-mc/dragonfly/server/block/cube"
"github.com/df-mc/dragonfly/server/item"
"github.com/df-mc/dragonfly/server/player"
"github.com/df-mc/dragonfly/server/player/chat"
"github.com/sirupsen/logrus"
"time"
)
func main() {
log := logrus.New()
log.Formatter = &logrus.TextFormatter{ForceColors: true}
log.Level = logrus.InfoLevel
chat.Global.Subscribe(chat.StdoutSubscriber{})
conf, err := server.DefaultConfig().Config(log)
if err != nil {
log.Fatalln(err)
}
srv := conf.New()
srv.CloseOnProgramEnd()
srv.Listen()
inv.PlaceFakeContainer(srv.World(), cube.Pos{0, 255, 0})
for srv.Accept(accept) {
}
}
func accept(p *player.Player) {
intercept.Intercept(p)
time.AfterFunc(1*time.Second, func() {
sub := MySubmittable{}
var stacks = make([]item.Stack, 54)
for i := 0; i < 54; i++ {
stacks[i] = item.NewStack(block.StainedGlass{Colour: item.ColourRed()}, 1)
}
m := inv.NewMenu(sub, "test", inv.ContainerChest{DoubleChest: true}).WithStacks(stacks...)
inv.SendMenu(p, m)
})
}
type MySubmittable struct{}
func (m MySubmittable) Submit(p *player.Player, it item.Stack) {
fmt.Println("Submitted", it)
}
func (m MySubmittable) Close(p *player.Player) {
fmt.Println("Closed")
}