up3
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"github.com/google/uuid"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
"time"
|
||||
)
|
||||
|
||||
// EmoteHandler handles the Emote packet.
|
||||
type EmoteHandler struct {
|
||||
LastEmote time.Time
|
||||
}
|
||||
|
||||
// Handle ...
|
||||
func (h *EmoteHandler) Handle(p packet.Packet, _ *Session, tx *world.Tx, c Controllable) error {
|
||||
pk := p.(*packet.Emote)
|
||||
|
||||
if pk.EntityRuntimeID != selfEntityRuntimeID {
|
||||
return errSelfRuntimeID
|
||||
}
|
||||
if time.Since(h.LastEmote) < time.Second {
|
||||
return nil
|
||||
}
|
||||
h.LastEmote = time.Now()
|
||||
emote, err := uuid.Parse(pk.EmoteID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, viewer := range tx.Viewers(c.Position()) {
|
||||
viewer.ViewEmote(c, emote)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user