From a026982d260972be37d2251e2607e5f0db35643f Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Wed, 29 Apr 2026 13:56:05 +0200 Subject: [PATCH] feat: Go Guide --- docs/.vitepress/en.ts | 14 +++++++ docs/de/plugin-dev/introduction.md | 3 +- docs/en/plugin-dev/go/basic-logic.md | 60 +++++++++++++++++++++++++++ docs/en/plugin-dev/go/quick-start.md | 35 ++++++++++++++++ docs/en/plugin-dev/introduction.md | 3 +- docs/nl/plugin-dev/introduction.md | 3 +- docs/pt/plugin-dev/introduction.md | 3 +- docs/tr_TR/plugin-dev/introduction.md | 3 +- docs/zh_cn/plugin-dev/introduction.md | 3 +- 9 files changed, 121 insertions(+), 6 deletions(-) create mode 100644 docs/en/plugin-dev/go/basic-logic.md create mode 100644 docs/en/plugin-dev/go/quick-start.md diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 345e06e..e8bbdd5 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -136,6 +136,20 @@ export const en = defineConfig({ }, ], }, + { + text: "Go", + collapsed: false, + items: [ + { + text: "Quick Start", + link: "/plugin-dev/go/quick-start", + }, + { + text: "Basic Logic", + link: "/plugin-dev/go/basic-logic", + }, + ], + }, ], }, { diff --git a/docs/de/plugin-dev/introduction.md b/docs/de/plugin-dev/introduction.md index 3e361af..fd6d032 100644 --- a/docs/de/plugin-dev/introduction.md +++ b/docs/de/plugin-dev/introduction.md @@ -7,10 +7,11 @@ Wenn du auf Probleme stößt, melde dich bitte auf unserem [Discord‑Server](ht Pumpkin‑Plugins integrieren sich sehr tief in die Server‑Software und ermöglichen dadurch viele Dinge, die auf anderer Serversoftware nicht möglich wären. -Die Pumpkin Plugin API orientiert sich in vielen Bereichen an der Spigot/Bukkit Plugin API. Wenn du damit bereits Erfahrung hast und Rust, Python, C# oder C beherrscht, solltest du relativ einfach Plugins für Pumpkin schreiben können. :smile: +Die Pumpkin Plugin API orientiert sich in vielen Bereichen an der Spigot/Bukkit Plugin API. Wenn du damit bereits Erfahrung hast und Rust, Python, C#, Go oder C beherrscht, solltest du relativ einfach Plugins für Pumpkin schreiben können. :smile: * [Rust API](https://github.com/Pumpkin-MC/Pumpkin) * [Python API](https://github.com/Pumpkin-MC/pumpkin-python) * [C# API](https://github.com/Pumpkin-MC/pumpkin-api-cs) +* [Go API](https://github.com/Pumpkin-MC/pumpkin-api-go) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/en/plugin-dev/go/basic-logic.md b/docs/en/plugin-dev/go/basic-logic.md new file mode 100644 index 0000000..7e0e4a6 --- /dev/null +++ b/docs/en/plugin-dev/go/basic-logic.md @@ -0,0 +1,60 @@ +# Writing the basic logic + +## Plugin Entry Point + +In Go, your plugin must implement the `api.Plugin` interface and register itself in the `init()` function. You also need to import `wit_exports` for WebAssembly compatibility. + +:::code-group + +```go [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" // Required for WASM 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() {} +``` + +::: + +## Compiling the plugin + +To compile your plugin to WebAssembly, you must use **TinyGo**. The standard Go compiler does not yet support the specific WASI targets required by Pumpkin in the same way. + +Run the following command in your project folder: + +```bash +tinygo build -o my_plugin.wasm -target=wasi main.go +``` + +This will generate a `my_plugin.wasm` file that can be loaded by Pumpkin. + +## Testing the plugin + +Installing a plugin is as simple as putting the plugin binary (`.wasm`) into the `plugins/` folder of your Pumpkin server! + +When you start up the server and run the `/plugins` command, you should see your plugin listed. diff --git a/docs/en/plugin-dev/go/quick-start.md b/docs/en/plugin-dev/go/quick-start.md new file mode 100644 index 0000000..90bacb4 --- /dev/null +++ b/docs/en/plugin-dev/go/quick-start.md @@ -0,0 +1,35 @@ +# Creating a new project + +Pumpkin plugins use the [Go](https://go.dev/) programming language and are compiled to WebAssembly. + +## Prerequisites + +Before we can start, make sure you have the following installed: +- [Go](https://go.dev/doc/install) (latest version recommended) +- [TinyGo](https://tinygo.org/getting-started/install/) (required for WASM compilation) + +## Initializing a new module + +First, create a new directory for your project and initialize a Go module: + +```bash +mkdir hello-pumpkin +cd hello-pumpkin +go mod init github.com/yourname/hello-pumpkin +``` + +Next, add the Pumpkin Go API as a dependency: + +```bash +go get github.com/Pumpkin-MC/pumpkin-api-go +``` + +## Project Structure + +Your project should have at least a `main.go` file. The structure should look like this: + +```text +├── go.mod +├── go.sum +└── main.go +``` diff --git a/docs/en/plugin-dev/introduction.md b/docs/en/plugin-dev/introduction.md index fb1029b..0b32d26 100644 --- a/docs/en/plugin-dev/introduction.md +++ b/docs/en/plugin-dev/introduction.md @@ -6,10 +6,11 @@ If you run into any issues please reach out on [our Discord server](https://disc ::: The Pumpkin Plugin API takes inspiration from the Spigot/Bukkit plugin API in many places, -so if you have previous experience with these and have experience with Rust, Python, C#, or C development, +so if you have previous experience with these and have experience with Rust, Python, C#, Go, or C development, you should have a pretty easy time writing plugins for Pumpkin. :smile: * [Rust API](https://github.com/Pumpkin-MC/Pumpkin) * [Python API](https://github.com/Pumpkin-MC/pumpkin-python) * [C# API](https://github.com/Pumpkin-MC/pumpkin-api-cs) +* [Go API](https://github.com/Pumpkin-MC/pumpkin-api-go) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/nl/plugin-dev/introduction.md b/docs/nl/plugin-dev/introduction.md index 3231db1..0f9cb5f 100644 --- a/docs/nl/plugin-dev/introduction.md +++ b/docs/nl/plugin-dev/introduction.md @@ -6,10 +6,11 @@ Als je problemen ondervindt, neem dan contact op via [onze discord](https://disc Pumpkin Plugins integreren op een zeer diep niveau met de server software, waardoor veel dingen mogelijk zijn die op andere server software niet mogelijk zouden zijn. -De Pumpkin Plugin API haalt inspiratie uit de Spigot/Bukkit plugin API op veel plaatsen, dus als je eerdere ervaring hebt met deze en ervaring hebt met Rust, Python, C# of C ontwikkeling, zou je vrij gemakkelijk plugins voor Pumpkin moeten kunnen schrijven :smile: +De Pumpkin Plugin API haalt inspiratie uit de Spigot/Bukkit plugin API op veel plaatsen, dus als je eerdere ervaring hebt met deze en ervaring hebt met Rust, Python, C#, Go of C ontwikkeling, zou je vrij gemakkelijk plugins voor Pumpkin moeten kunnen schrijven :smile: * [Rust API](https://github.com/Pumpkin-MC/Pumpkin) * [Python API](https://github.com/Pumpkin-MC/pumpkin-python) * [C# API](https://github.com/Pumpkin-MC/pumpkin-api-cs) +* [Go API](https://github.com/Pumpkin-MC/pumpkin-api-go) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/pt/plugin-dev/introduction.md b/docs/pt/plugin-dev/introduction.md index 94b2d7b..74f092e 100644 --- a/docs/pt/plugin-dev/introduction.md +++ b/docs/pt/plugin-dev/introduction.md @@ -7,9 +7,10 @@ Se você encontrar algum problema, por favor, entre em contato em [nosso servido Os Plugins Pumpkin se integram ao software do servidor de maneira muito profunda, permitindo muitas coisas que não seriam possíveis em outros softwares de servidor. -A API de Plugins Pumpkin se inspira na API de plugins do Spigot/Bukkit em diversos aspectos, então, se você tem experiência prévia com os mesmos e possui experiência com desenvolvimento em Rust, Python, C# ou C, você terá uma experiência relativamente fácil ao escrever plugins para o Pumpkin. :smile: +A API de Plugins Pumpkin se inspira na API de plugins do Spigot/Bukkit em diversos aspectos, então, se você tem experiência prévia com os mesmos e possui experiência com desenvolvimento em Rust, Python, C#, Go ou C, você terá uma experiência relativamente fácil ao escrever plugins para o Pumpkin. :smile: * [Rust API](https://github.com/Pumpkin-MC/Pumpkin) * [Python API](https://github.com/Pumpkin-MC/pumpkin-python) * [C# API](https://github.com/Pumpkin-MC/pumpkin-api-cs) +* [Go API](https://github.com/Pumpkin-MC/pumpkin-api-go) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/tr_TR/plugin-dev/introduction.md b/docs/tr_TR/plugin-dev/introduction.md index a080069..91a003b 100644 --- a/docs/tr_TR/plugin-dev/introduction.md +++ b/docs/tr_TR/plugin-dev/introduction.md @@ -7,9 +7,10 @@ Herhangi bir sorunla karşılaşırsanız lütfen [Discord sunucumuzdan](https:/ Pumpkin Eklentileri, sunucu yazılımıyla çok derin bir seviyede entegre olur ve diğer sunucu yazılımlarında mümkün olmayacak birçok şeye olanak tanır. -Pumpkin Eklenti API'si birçok yerde Spigot/Bukkit eklenti API'sinden ilham alır; daha önce bunlarla deneyiminiz ve Rust, Python, C# veya C geliştirme tecrübeniz varsa Pumpkin için eklenti yazmanız oldukça kolay olacaktır. :smile: +Pumpkin Eklenti API'si birçok yerde Spigot/Bukkit eklenti API'sinden ilham alır; daha önce bunlarla deneyiminiz ve Rust, Python, C#, Go veya C geliştirme tecrübeniz varsa Pumpkin için eklenti yazmanız oldukça kolay olacaktır. :smile: * [Rust API](https://github.com/Pumpkin-MC/Pumpkin) * [Python API](https://github.com/Pumpkin-MC/pumpkin-python) * [C# API](https://github.com/Pumpkin-MC/pumpkin-api-cs) +* [Go API](https://github.com/Pumpkin-MC/pumpkin-api-go) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/zh_cn/plugin-dev/introduction.md b/docs/zh_cn/plugin-dev/introduction.md index c5aa618..da4ecc5 100644 --- a/docs/zh_cn/plugin-dev/introduction.md +++ b/docs/zh_cn/plugin-dev/introduction.md @@ -7,9 +7,10 @@ Pumpkin 插件 API 仍处于非常早期的开发阶段,可能随时会发生 Pumpkin 插件与服务器软件在很深的层次上集成,允许实现其他服务器软件无法实现的许多功能。 -Pumpkin 插件 API 在很多方面受到 Spigot/Bukkit 插件 API 的启发,因此如果您有这些 API 的使用经验并且熟悉 Rust、Python、C# 或 C 开发,您应该能够相对轻松地为 Pumpkin 编写插件。 :smile: +Pumpkin 插件 API 在很多方面受到 Spigot/Bukkit 插件 API 的启发,因此如果您有这些 API 的使用经验并且熟悉 Rust、Python、C#、Go 或 C 开发,您应该能够相对轻松地为 Pumpkin 编写插件。 :smile: * [Rust API](https://github.com/Pumpkin-MC/Pumpkin) * [Python API](https://github.com/Pumpkin-MC/pumpkin-python) * [C# API](https://github.com/Pumpkin-MC/pumpkin-api-cs) +* [Go API](https://github.com/Pumpkin-MC/pumpkin-api-go) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c)