Documentation ¶
Index ¶
- Variables
- func Command(fn func(c *Context) error) brigodier.Command
- func ContextWithSource(ctx context.Context, src Source) context.Context
- func Requires(fn func(c *RequiresContext) bool) func(context.Context) bool
- type Context
- type Manager
- func (m *Manager) CompletionSuggestions(parse *ParseResults) (*brigodier.Suggestions, error)
- func (m *Manager) Do(ctx context.Context, src Source, command string) error
- func (m *Manager) Execute(parse *ParseResults) error
- func (m *Manager) Has(command string) bool
- func (m *Manager) OfferSuggestions(ctx context.Context, source Source, cmdline string) ([]string, error)
- func (m *Manager) Parse(ctx context.Context, src Source, command string) *ParseResults
- func (m *Manager) ParseReader(ctx context.Context, src Source, command *brigodier.StringReader) *ParseResults
- type MessageOption
- type ParseResults
- type RequiresContext
- type Source
- type SuggestFunc
Constants ¶
This section is empty.
Variables ¶
var ErrForward = errors.New("forward command")
Functions ¶
func ContextWithSource ¶
ContextWithSource returns a new context including the specified Source.
Types ¶
type Context ¶
type Context struct { *brigodier.CommandContext Source }
Context wraps the context for a brigodier.Command.
type Manager ¶
type Manager struct{ brigodier.Dispatcher }
Manager is a command manager for registering and executing proxy commands.
func (*Manager) CompletionSuggestions ¶
func (m *Manager) CompletionSuggestions(parse *ParseResults) (*brigodier.Suggestions, error)
CompletionSuggestions returns completion suggestions.
func (*Manager) Execute ¶
func (m *Manager) Execute(parse *ParseResults) error
Execute ensures parse context has a Source and executes it.
func (*Manager) OfferSuggestions ¶
func (m *Manager) OfferSuggestions(ctx context.Context, source Source, cmdline string) ([]string, error)
OfferSuggestions returns completion suggestions.
func (*Manager) Parse ¶
Parse stores a required command invoker Source in ctx, parses the command and returns parse results for use with Execute.
func (*Manager) ParseReader ¶
func (m *Manager) ParseReader(ctx context.Context, src Source, command *brigodier.StringReader) *ParseResults
ParseReader stores a required command invoker Source in ctx, parses the command and returns parse results for use with Execute.
type MessageOption ¶ added in v0.19.0
type MessageOption interface {
Apply(o any)
}
type ParseResults ¶
type ParseResults brigodier.ParseResults
ParseResults are the parse results of a parsed command input.
It overlays brigodier.ParseResults to make clear that Manager.Execute must only get parse results returned by Manager.Parse.
type RequiresContext ¶
RequiresContext wraps the context for a brigodier.RequireFn.
type Source ¶
type Source interface { permission.Subject // SendMessage sends a message component to the invoker. SendMessage(msg component.Component, opts ...MessageOption) error }
Source is the invoker of a command. It could be a player or the console/terminal.
func SourceFromContext ¶
SourceFromContext retrieves the Source from a command's context.
type SuggestFunc ¶
type SuggestFunc func( c *Context, b *brigodier.SuggestionsBuilder) *brigodier.Suggestions
SuggestFunc is a convenient function type implementing the brigodier.SuggestionProvider interface.
func (SuggestFunc) Suggestions ¶
func (s SuggestFunc) Suggestions( c *brigodier.CommandContext, b *brigodier.SuggestionsBuilder) *brigodier.Suggestions