github.com/df-mc/dragonfly@v0.9.13/server/session/handler_emote.go (about) 1 package session 2 3 import ( 4 "github.com/google/uuid" 5 "github.com/sandertv/gophertunnel/minecraft/protocol/packet" 6 "time" 7 ) 8 9 // EmoteHandler handles the Emote packet. 10 type EmoteHandler struct { 11 LastEmote time.Time 12 } 13 14 // Handle ... 15 func (h *EmoteHandler) Handle(p packet.Packet, s *Session) error { 16 pk := p.(*packet.Emote) 17 18 if pk.EntityRuntimeID != selfEntityRuntimeID { 19 return errSelfRuntimeID 20 } 21 if time.Since(h.LastEmote) < time.Second { 22 return nil 23 } 24 h.LastEmote = time.Now() 25 emote, err := uuid.Parse(pk.EmoteID) 26 if err != nil { 27 return err 28 } 29 for _, viewer := range s.c.World().Viewers(s.c.Position()) { 30 viewer.ViewEmote(s.c, emote) 31 } 32 return nil 33 }