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,32 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/df-mc/dragonfly/server/player/dialogue"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"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, tx *world.Tx, c Controllable) error {
|
||||
pk := p.(*packet.NPCRequest)
|
||||
if h.entityRuntimeID == 0 {
|
||||
// No dialogue is currently open for this session, so there is nothing to submit or close.
|
||||
return nil
|
||||
}
|
||||
switch pk.RequestType {
|
||||
case packet.NPCRequestActionExecuteAction:
|
||||
if err := h.dialogue.Submit(uint(pk.ActionType), c, tx); err != nil {
|
||||
return fmt.Errorf("error submitting dialogue: %w", err)
|
||||
}
|
||||
case packet.NPCRequestActionExecuteClosingCommands:
|
||||
h.dialogue.Close(c, tx)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user