Pumpkin Plugin API for Go
Go to file
2026-08-15 10:59:24 -07:00
api first commit 2026-04-29 13:42:26 +02:00
example first commit 2026-04-29 13:45:05 +02:00
internal/exports first commit 2026-04-29 13:45:05 +02:00
pkg first commit 2026-04-29 13:45:05 +02:00
wit first commit 2026-04-29 13:42:26 +02:00
.gitmodules first commit 2026-04-29 13:42:26 +02:00
generate.sh first commit 2026-04-29 13:45:05 +02:00
go.mod first commit 2026-04-29 13:45:05 +02:00
go.sum first commit 2026-04-29 13:45:05 +02:00
LICENSE-APACHE Relicense under MIT OR Apache-2.0 2026-08-15 10:59:24 -07:00
LICENSE-MIT Relicense under MIT OR Apache-2.0 2026-08-15 10:59:24 -07:00
README.md first commit 2026-04-29 13:45:05 +02:00

Pumpkin Plugin API for Go

This package provides everything needed to write a Pumpkin server plugin compiled to WebAssembly using Go.

Quick start

  1. Initialize your Go module:
go mod init github.com/yourname/yourplugin
go get github.com/Pumpkin-MC/pumpkin-api-go
  1. Create your plugin (main.go):
package main

import (
	"github.com/Pumpkin-MC/pumpkin-api-go/api"
	"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_context"
	"github.com/Pumpkin-MC/pumpkin-api-go/pkg/pumpkin_plugin_logging"
	_ "github.com/Pumpkin-MC/pumpkin-api-go/pkg/wit_exports"
)

type MyPlugin struct {
	api.DefaultPlugin
}

func (p *MyPlugin) Metadata() api.Metadata {
	return api.Metadata{
		Name:    "my-go-plugin",
		Version: "0.1.0",
		Authors: []string{"you"},
	}
}

func (p *MyPlugin) OnLoad(ctx *pumpkin_plugin_context.Context) {
    pumpkin_plugin_logging.Log(pumpkin_plugin_logging.LevelInfo(), "Go plugin loaded!")
}

func init() {
	api.RegisterPlugin(&MyPlugin{})
}

func main() {}
  1. Build your plugin into a WebAssembly component using TinyGo:
tinygo build -o my_plugin.wasm -target=wasi main.go

Note: You might need to use wit-component to turn the core WASM into a component if your build tool doesn't do it automatically.