Skip to content

About

Pumpkin Plugin API for Go

Resources

Stars

14 stars

Watchers

2 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

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.

About

Pumpkin Plugin API for Go

Resources

Stars

14 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages