Add playerinfo recorder for chat message

This commit is contained in:
Tnze
2022-12-30 01:09:08 +08:00
parent 6fba193255
commit 77857a1a85
6 changed files with 206 additions and 39 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/Tnze/go-mc/bot"
"github.com/Tnze/go-mc/bot/basic"
"github.com/Tnze/go-mc/bot/msg"
"github.com/Tnze/go-mc/chat"
_ "github.com/Tnze/go-mc/data/lang/en-us"
"github.com/Tnze/go-mc/data/packetid"
@ -18,9 +17,8 @@ import (
const timeout = 45
var (
c *bot.Client
p *basic.Player
bc *msg.Manager
c *bot.Client
p *basic.Player
watch chan time.Time
)
@ -34,7 +32,6 @@ func main() {
Disconnect: onDisconnect,
Death: onDeath,
})
bc = msg.New(c, p, msg.EventsHandler{PlayerChatMessage: onChatMsg})
// Register event handlers

View File

@ -13,6 +13,7 @@ import (
"github.com/Tnze/go-mc/bot"
"github.com/Tnze/go-mc/bot/basic"
"github.com/Tnze/go-mc/bot/msg"
"github.com/Tnze/go-mc/bot/playerlist"
"github.com/Tnze/go-mc/bot/screen"
"github.com/Tnze/go-mc/bot/world"
"github.com/Tnze/go-mc/chat"
@ -31,6 +32,7 @@ var (
var (
client *bot.Client
player *basic.Player
playerList *playerlist.PlayerList
chatHandler *msg.Manager
worldManager *world.World
screenManager *screen.Manager
@ -52,7 +54,8 @@ func main() {
HealthChange: onHealthChange,
Death: onDeath,
})
chatHandler = msg.New(client, player, msg.EventsHandler{
playerList = playerlist.New(client)
chatHandler = msg.New(client, player, playerList, msg.EventsHandler{
PlayerChatMessage: onPlayerMsg,
})
worldManager = world.NewWorld(client, player, world.EventsListener{