Skip to main content
The Proxy type is Gate’s main Java edition Minecraft proxy interface. It provides methods for managing servers, players, commands, and events.

Overview

The Proxy is the central component that:
  • Manages backend server registrations
  • Tracks connected players
  • Handles event management
  • Processes commands
  • Controls the proxy lifecycle
Source: pkg/edition/java/proxy/proxy.go:42

Creating a Proxy

Create a new proxy instance with configuration:
*config.Config
required
The proxy configuration. Must be validated before passing.
event.Manager
Event manager for the proxy. If nil, no events are sent.
auth.Authenticator
Custom authenticator for online mode. If nil, uses Mojang’s session server.

Starting the Proxy

Start the proxy and begin accepting connections:
error
Returns ErrProxyAlreadyRun if the proxy was already started, or any initialization/runtime errors.
A Proxy instance can only be run once. Create a new instance to restart.

Server Management

Registering Servers

Register a backend server with the proxy:
ServerInfo
required
Server information including name and address.
RegisteredServer
The registered server instance.
error
Returns ErrServerAlreadyExists if a server with the same name already exists.

Getting Servers

Retrieve registered servers:
RegisteredServer
Returns nil if the server is not found.

Unregistering Servers

Remove a server from the proxy:
bool
Returns true if the server was found and unregistered.

Player Management

Getting Players

Retrieve connected players:
Player
Returns nil if the player is not found.

Disconnecting Players

Disconnect all connected players:
component.Component
The disconnect reason to display to players.

Event Management

Access the proxy’s event manager:
event.Manager
The proxy’s event manager for subscribing to and firing events.

Command Management

Access the proxy’s command manager:
*command.Manager
The proxy’s command manager for registering and managing commands.

Configuration

Access the current proxy configuration:
config.Config
A copy of the current proxy configuration.

Shutdown

Shutdown the proxy gracefully:
The shutdown process:
  1. Stops listening for new connections
  2. Fires PreShutdownEvent allowing modification of disconnect reason
  3. Disconnects all players with the provided reason
  4. Fires ShutdownEvent and waits for all event handlers
  5. Cleans up resources
component.Component
The reason to display to players when disconnecting. Pass nil for blank reason.

Lite Mode

Access lite mode functionality:
*lite.Lite
The proxy’s lite mode functionality handler.

Plugin Channel Registry

Access the plugin message channel registrar:
*message.ChannelRegistrar
The channel registrar for plugin messages.

Complete Example

See Also