Skip to content

Commit

Permalink
session/handler_npc_request.go: Missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedAsylumMC committed Nov 17, 2024
1 parent 33cd74f commit e798ed1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions server/session/handler_npc_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package session

import (
"fmt"
"github.com/df-mc/dragonfly/server/player/dialogue"
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
)

// NPCRequestHandler handles the NPCRequest packet.
type NPCRequestHandler struct {
dialogue dialogue.Dialogue
entityRuntimeID uint64
}

// Handle ...
func (h *NPCRequestHandler) Handle(p packet.Packet, s *Session) error {
pk := p.(*packet.NPCRequest)
if pk.RequestType == packet.NPCRequestActionExecuteAction {
if err := h.dialogue.Submit(uint(pk.ActionType), s.c); err != nil {
return fmt.Errorf("error submitting dialogue: %w", err)
}
} else if pk.RequestType == packet.NPCRequestActionExecuteClosingCommands {
h.dialogue.Close(s.c)
}
return nil
}

0 comments on commit e798ed1

Please sign in to comment.