Files
mc/server/session/handler_command_request.go
T

26 lines
671 B
Go
Raw Normal View History

2026-07-09 08:33:57 +08:00
package session
import (
"fmt"
"github.com/df-mc/dragonfly/server/world"
"github.com/sandertv/gophertunnel/minecraft/protocol"
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
)
// CommandRequestHandler handles the CommandRequest packet.
type CommandRequestHandler struct {
origin protocol.CommandOrigin
}
// Handle ...
func (h *CommandRequestHandler) Handle(p packet.Packet, _ *Session, _ *world.Tx, c Controllable) error {
pk := p.(*packet.CommandRequest)
if pk.Internal {
return fmt.Errorf("command request packet must never have the internal field set to true")
}
h.origin = pk.CommandOrigin
c.ExecuteCommand(pk.CommandLine)
return nil
}