move SystemChat event from bot/basic
to bot/msg
This commit is contained in:
@ -15,7 +15,6 @@
|
||||
// Handles some basic event you probably need.
|
||||
// - GameStart
|
||||
// - ChatMsg
|
||||
// - SystemMsg
|
||||
// - Disconnect
|
||||
// - HealthChange
|
||||
// - Death
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
|
||||
type EventsListener struct {
|
||||
GameStart func() error
|
||||
SystemMsg func(c chat.Message, overlay bool) error
|
||||
Disconnect func(reason chat.Message) error
|
||||
HealthChange func(health float32) error
|
||||
Death func() error
|
||||
@ -21,9 +20,6 @@ func (e EventsListener) attach(p *Player) {
|
||||
if e.GameStart != nil {
|
||||
attachJoinGameHandler(p.c, e.GameStart)
|
||||
}
|
||||
if e.SystemMsg != nil {
|
||||
attachSystemMsg(p.c, e.SystemMsg)
|
||||
}
|
||||
if e.Disconnect != nil {
|
||||
attachDisconnect(p.c, e.Disconnect)
|
||||
}
|
||||
@ -41,20 +37,6 @@ func attachJoinGameHandler(c *bot.Client, handler func() error) {
|
||||
})
|
||||
}
|
||||
|
||||
func attachSystemMsg(c *bot.Client, handler func(c chat.Message, overlay bool) error) {
|
||||
c.Events.AddListener(bot.PacketHandler{
|
||||
Priority: 64, ID: packetid.ClientboundSystemChat,
|
||||
F: func(p pk.Packet) error {
|
||||
var msg chat.Message
|
||||
var pos pk.Boolean
|
||||
if err := p.Scan(&msg, &pos); err != nil {
|
||||
return Error{err}
|
||||
}
|
||||
return handler(msg, bool(pos))
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func attachDisconnect(c *bot.Client, handler func(reason chat.Message) error) {
|
||||
c.Events.AddListener(bot.PacketHandler{
|
||||
Priority: 64, ID: packetid.ClientboundDisconnect,
|
||||
|
Reference in New Issue
Block a user