Skip to main content

Plugin Template

The fastest way to start building with Gate is to use our official plugin template. It provides a complete, working example with all the boilerplate configured.

What’s Included

The gate-plugin-template repository includes:
  • Pre-configured Go module with Gate dependencies
  • Example plugin code demonstrating common patterns
  • Build configuration with Makefile
  • Docker support for containerized deployments
  • CI/CD examples for automated builds
  • Documentation and code comments

Quick Start

1

Fork or Clone the Template

Visit the gate-plugin-template repository and fork it to your GitHub account, or clone it directly:
2

Install Dependencies

Download the required Go modules:
This will fetch Gate and all its dependencies.
3

Explore the Code

Open plugin.go to see the example plugin implementation. The template includes:
  • Plugin initialization hook
  • Example command registration
  • Event listener examples
  • Common API usage patterns
4

Build and Run

Compile and run your plugin:
Or use the provided Makefile:
5

Connect and Test

Connect to your proxy using a Minecraft client:
Try the example commands included in the template.

Template Structure

The template is organized as follows:

Key Files

plugin.go: Contains your plugin’s main logic
go.mod: Declares your module and Gate dependency
config.yml: Gate’s configuration file

Customizing the Template

1. Update Module Name

Edit go.mod to reflect your project:
Then update imports:

2. Rename Your Plugin

In plugin.go, change the plugin name:

3. Add Your Features

Extend the initialization function to add your custom logic:

Common Patterns

The template demonstrates several common patterns:

Command Registration

Event Subscription

Accessing Player Data

Building for Production

Compile Optimized Binary

Flags:
  • CGO_ENABLED=0: Disable C dependencies for pure Go binary
  • -ldflags="-s -w": Strip debug info to reduce binary size

Cross-Compile for Linux

From macOS or Windows:

Docker Build

The template includes a Dockerfile:

Configuration Management

Environment Variables

Gate supports environment variable overrides:

Custom Config Path

Config Validation

Gate validates your configuration on startup and logs any errors or warnings.

Troubleshooting

Build Errors

Solution: Download dependencies first:
Solution: Update your go.mod and download missing packages:
Solution: Check for config.yml in the working directory:

Runtime Issues

Solution: Another process is using port 25565. Either stop it or change the port in config.yml:
Solution: Verify backend servers are running and accessible:
Check your config.yml server addresses are correct.
Solution: Ensure commands are registered before Gate starts:

Updating Gate Version

To update to the latest Gate version:
Check the changelog for breaking changes.

Next Steps

Now that you have the template running:

Learn Commands

Register custom commands for your players

Handle Events

React to player actions and server events

View Examples

Study the complete simple-proxy example

API Reference

Explore the full API documentation

Resources