Skip to main content

Commands Overview

Gate provides a powerful command system built on top of the Brigadier library, allowing you to register custom proxy commands that players can execute.

Command Architecture

Gate’s command system consists of several key components:

Command Manager

The command.Manager handles command registration and execution:
type Manager struct { 
    brigodier.Dispatcher 
}
Source: pkg/command/command.go:14-15

Command Source

The Source interface represents the command invoker (player or console):
type Source interface {
    permission.Subject
    SendMessage(msg component.Component, opts ...MessageOption) error
}
Source: pkg/command/command.go:19-23

Basic Concepts

Command Context

Every command receives a Context containing:
  • Command arguments
  • Source (who executed the command)
  • Parsed parameters
type Context struct {
    *brigodier.CommandContext
    Source
}

Command Execution

Commands are executed through a pipeline:
  1. Parse: Command input is parsed into a ParseResults
  2. Execute: Parsed command is executed with context
  3. Response: Results are sent back to the source
// Do combines Parse and Execute
func (m *Manager) Do(ctx context.Context, src Source, command string) error
Source: pkg/command/command.go:102-104

Built-in Commands

Gate includes several built-in commands:
CommandDescriptionPermission
/serverSwitch or list serversgate.command.server
/glistList online playersgate.command.glist
/sendSend player to servergate.command.send
Built-in commands can be disabled via builtinCommands: false in config.yml.

Next Steps

Command Registration

Learn how to register custom commands

Using Brigadier

Master Brigadier’s node system

Permissions

Implement permission checks

Command Examples

See complete command implementations

Build docs developers (and LLMs) love