feat: add c plugin tutorial
This commit is contained in:
parent
ec05946631
commit
271e98f412
@ -118,6 +118,16 @@ export const de = defineConfig({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "C",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: "Schnellstart",
|
||||
link: "/de/plugin-dev/c/quick-start",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@ -116,6 +116,16 @@ export const en = defineConfig({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "C",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: "Quick Start",
|
||||
link: "/plugin-dev/c/quick-start",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@ -99,6 +99,16 @@ export const nl = defineConfig({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "C",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: "Snelstart",
|
||||
link: "/nl/plugin-dev/c/quick-start",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@ -99,6 +99,16 @@ export const pt = defineConfig({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "C",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: "Início Rápido",
|
||||
link: "/pt/plugin-dev/c/quick-start",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@ -118,6 +118,16 @@ export const trTR = defineConfig({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "C",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: "Hızlı Başlangıç",
|
||||
link: "/tr_TR/plugin-dev/c/quick-start",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@ -124,6 +124,16 @@ export const zhCN = defineConfig({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
text: "C",
|
||||
collapsed: false,
|
||||
items: [
|
||||
{
|
||||
text: "快速入门",
|
||||
link: "/zh_cn/plugin-dev/c/quick-start",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
64
docs/de/plugin-dev/c/quick-start.md
Normal file
64
docs/de/plugin-dev/c/quick-start.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Schnellstart
|
||||
|
||||
Dieser Leitfaden hilft dir beim Einstieg in das Schreiben von Pumpkin-Server-Plugins mit C.
|
||||
|
||||
## Voraussetzungen
|
||||
|
||||
Bevor du beginnst, stelle sicher, dass du Folgendes installiert hast:
|
||||
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk/releases) (zum Kompilieren von C nach WASI)
|
||||
- `git` (um die API zu klonen)
|
||||
|
||||
## Projekt einrichten
|
||||
|
||||
Klone zuerst das Pumpkin C API Repository mit Submodulen:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/Pumpkin-MC/pumpkin-api-c.git
|
||||
cd pumpkin-api-c
|
||||
```
|
||||
|
||||
## Dein erstes Plugin erstellen
|
||||
|
||||
Erstelle eine Datei namens `main.c` im Stammverzeichnis des Repositories und füge den folgenden Inhalt hinzu:
|
||||
|
||||
```c
|
||||
#include "pumpkin_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
pumpkin_metadata_t get_meta(void) {
|
||||
static const char* authors[] = {"you"};
|
||||
return (pumpkin_metadata_t) {
|
||||
.name = "my-c-plugin",
|
||||
.version = "0.1.0",
|
||||
.authors = authors,
|
||||
.authors_count = 1,
|
||||
.description = "Ein einfaches C-Plugin für Pumpkin",
|
||||
.dependencies_count = 0
|
||||
};
|
||||
}
|
||||
|
||||
void on_load(plugin_own_context_t ctx) {
|
||||
printf("C-Plugin geladen!\n");
|
||||
}
|
||||
|
||||
REGISTER_PUMPKIN_PLUGIN(((pumpkin_plugin_t){
|
||||
.get_metadata = get_meta,
|
||||
.on_load = on_load
|
||||
}))
|
||||
```
|
||||
|
||||
## Plugin bauen
|
||||
|
||||
Um dein Plugin in eine WebAssembly-Komponente zu bauen, verwende den `clang`-Compiler aus deiner `wasi-sdk`-Installation.
|
||||
|
||||
Ersetze `/path/to/wasi-sdk` durch den tatsächlichen Pfad zu deinem WASI SDK.
|
||||
|
||||
```bash
|
||||
/path/to/wasi-sdk/bin/clang -O3 \
|
||||
-Iinclude -Isrc/gen \
|
||||
src/gen/plugin.c src/pumpkin_api.c main.c \
|
||||
-o my_plugin.wasm \
|
||||
-mexec-model=reactor
|
||||
```
|
||||
|
||||
Dies generiert eine `my_plugin.wasm`-Datei, die du im `plugins`-Ordner deines Pumpkin-Servers ablegen kannst.
|
||||
@ -7,4 +7,9 @@ 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 beherrschst, 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 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-c)
|
||||
|
||||
|
||||
64
docs/en/plugin-dev/c/quick-start.md
Normal file
64
docs/en/plugin-dev/c/quick-start.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Quick Start
|
||||
|
||||
This guide will help you get started with writing Pumpkin server plugins using C.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you start, ensure you have the following installed:
|
||||
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk/releases) (for compiling C to WASI)
|
||||
- `git` (to clone the API)
|
||||
|
||||
## Setting up the project
|
||||
|
||||
First, clone the Pumpkin C API repository with submodules:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/Pumpkin-MC/pumpkin-api-c.git
|
||||
cd pumpkin-api-c
|
||||
```
|
||||
|
||||
## Creating your first plugin
|
||||
|
||||
Create a file named `main.c` in the root of the repository and add the following content:
|
||||
|
||||
```c
|
||||
#include "pumpkin_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
pumpkin_metadata_t get_meta(void) {
|
||||
static const char* authors[] = {"you"};
|
||||
return (pumpkin_metadata_t) {
|
||||
.name = "my-c-plugin",
|
||||
.version = "0.1.0",
|
||||
.authors = authors,
|
||||
.authors_count = 1,
|
||||
.description = "A simple C plugin for Pumpkin",
|
||||
.dependencies_count = 0
|
||||
};
|
||||
}
|
||||
|
||||
void on_load(plugin_own_context_t ctx) {
|
||||
printf("C plugin loaded!\n");
|
||||
}
|
||||
|
||||
REGISTER_PUMPKIN_PLUGIN(((pumpkin_plugin_t){
|
||||
.get_metadata = get_meta,
|
||||
.on_load = on_load
|
||||
}))
|
||||
```
|
||||
|
||||
## Building the plugin
|
||||
|
||||
To build your plugin into a WebAssembly component, use the `clang` compiler from your `wasi-sdk` installation.
|
||||
|
||||
Replace `/path/to/wasi-sdk` with the actual path to your WASI SDK.
|
||||
|
||||
```bash
|
||||
/path/to/wasi-sdk/bin/clang -O3 \
|
||||
-Iinclude -Isrc/gen \
|
||||
src/gen/plugin.c src/pumpkin_api.c main.c \
|
||||
-o my_plugin.wasm \
|
||||
-mexec-model=reactor
|
||||
```
|
||||
|
||||
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||
@ -6,5 +6,9 @@ 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 development,
|
||||
so if you have previous experience with these and have experience with Rust, Python, 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-c)
|
||||
|
||||
64
docs/nl/plugin-dev/c/quick-start.md
Normal file
64
docs/nl/plugin-dev/c/quick-start.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Snelstart
|
||||
|
||||
Deze handleiding helpt je op weg bij het schrijven van Pumpkin server plugins met C.
|
||||
|
||||
## Vereisten
|
||||
|
||||
Zorg ervoor dat je het volgende hebt geïnstalleerd voordat je begint:
|
||||
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk/releases) (voor het compileren van C naar WASI)
|
||||
- `git` (om de API te klonen)
|
||||
|
||||
## Project opzetten
|
||||
|
||||
Kloon eerst de Pumpkin C API repository met submodules:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/Pumpkin-MC/pumpkin-api-c.git
|
||||
cd pumpkin-api-c
|
||||
```
|
||||
|
||||
## Je eerste plugin maken
|
||||
|
||||
Maak een bestand genaamd `main.c` aan in de hoofdmap van de repository en voeg de volgende inhoud toe:
|
||||
|
||||
```c
|
||||
#include "pumpkin_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
pumpkin_metadata_t get_meta(void) {
|
||||
static const char* authors[] = {"you"};
|
||||
return (pumpkin_metadata_t) {
|
||||
.name = "my-c-plugin",
|
||||
.version = "0.1.0",
|
||||
.authors = authors,
|
||||
.authors_count = 1,
|
||||
.description = "Een eenvoudige C-plugin voor Pumpkin",
|
||||
.dependencies_count = 0
|
||||
};
|
||||
}
|
||||
|
||||
void on_load(plugin_own_context_t ctx) {
|
||||
printf("C-plugin geladen!\n");
|
||||
}
|
||||
|
||||
REGISTER_PUMPKIN_PLUGIN(((pumpkin_plugin_t){
|
||||
.get_metadata = get_meta,
|
||||
.on_load = on_load
|
||||
}))
|
||||
```
|
||||
|
||||
## De plugin bouwen
|
||||
|
||||
Gebruik de `clang`-compiler van je `wasi-sdk`-installatie om je plugin naar een WebAssembly-component te bouwen.
|
||||
|
||||
Vervang `/path/to/wasi-sdk` door het daadwerkelijke pad naar je WASI SDK.
|
||||
|
||||
```bash
|
||||
/path/to/wasi-sdk/bin/clang -O3 \
|
||||
-Iinclude -Isrc/gen \
|
||||
src/gen/plugin.c src/pumpkin_api.c main.c \
|
||||
-o my_plugin.wasm \
|
||||
-mexec-model=reactor
|
||||
```
|
||||
|
||||
Dit genereert een `my_plugin.wasm`-bestand dat je in de `plugins`-map van je Pumpkin-server kunt plaatsen.
|
||||
@ -6,5 +6,9 @@ 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 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 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-c)
|
||||
|
||||
|
||||
64
docs/pt/plugin-dev/c/quick-start.md
Normal file
64
docs/pt/plugin-dev/c/quick-start.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Início Rápido
|
||||
|
||||
Este guia ajudará você a começar a escrever plugins para o servidor Pumpkin usando C.
|
||||
|
||||
## Pré-requisitos
|
||||
|
||||
Antes de começar, certifique-se de ter o seguinte instalado:
|
||||
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk/releases) (para compilar C para WASI)
|
||||
- `git` (para clonar a API)
|
||||
|
||||
## Configurando o projeto
|
||||
|
||||
Primeiro, clone o repositório da API C do Pumpkin com submódulos:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/Pumpkin-MC/pumpkin-api-c.git
|
||||
cd pumpkin-api-c
|
||||
```
|
||||
|
||||
## Criando seu primeiro plugin
|
||||
|
||||
Crie um arquivo chamado `main.c` na raiz do repositório e adicione o seguinte conteúdo:
|
||||
|
||||
```c
|
||||
#include "pumpkin_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
pumpkin_metadata_t get_meta(void) {
|
||||
static const char* authors[] = {"you"};
|
||||
return (pumpkin_metadata_t) {
|
||||
.name = "my-c-plugin",
|
||||
.version = "0.1.0",
|
||||
.authors = authors,
|
||||
.authors_count = 1,
|
||||
.description = "Um plugin C simples para o Pumpkin",
|
||||
.dependencies_count = 0
|
||||
};
|
||||
}
|
||||
|
||||
void on_load(plugin_own_context_t ctx) {
|
||||
printf("Plugin C carregado!\n");
|
||||
}
|
||||
|
||||
REGISTER_PUMPKIN_PLUGIN(((pumpkin_plugin_t){
|
||||
.get_metadata = get_meta,
|
||||
.on_load = on_load
|
||||
}))
|
||||
```
|
||||
|
||||
## Compilando o plugin
|
||||
|
||||
Para compilar seu plugin em um componente WebAssembly, use o compilador `clang` da sua instalação do `wasi-sdk`.
|
||||
|
||||
Substitua `/path/to/wasi-sdk` pelo caminho real do seu WASI SDK.
|
||||
|
||||
```bash
|
||||
/path/to/wasi-sdk/bin/clang -O3 \
|
||||
-Iinclude -Isrc/gen \
|
||||
src/gen/plugin.c src/pumpkin_api.c main.c \
|
||||
-o my_plugin.wasm \
|
||||
-mexec-model=reactor
|
||||
```
|
||||
|
||||
Isso gerará um arquivo `my_plugin.wasm` que você pode colocar na pasta `plugins` do seu servidor Pumpkin.
|
||||
@ -7,4 +7,8 @@ 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, 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 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-c)
|
||||
|
||||
64
docs/tr_TR/plugin-dev/c/quick-start.md
Normal file
64
docs/tr_TR/plugin-dev/c/quick-start.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Hızlı Başlangıç
|
||||
|
||||
Bu kılavuz, C kullanarak Pumpkin sunucu eklentileri yazmaya başlamanıza yardımcı olacaktır.
|
||||
|
||||
## Önkoşullar
|
||||
|
||||
Başlamadan önce şunların kurulu olduğundan emin olun:
|
||||
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk/releases) (C'yi WASI'ye derlemek için)
|
||||
- `git` (API'yi klonlamak için)
|
||||
|
||||
## Projeyi kurma
|
||||
|
||||
İlk olarak, Pumpkin C API deposunu alt modüllerle birlikte klonlayın:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/Pumpkin-MC/pumpkin-api-c.git
|
||||
cd pumpkin-api-c
|
||||
```
|
||||
|
||||
## İlk eklentinizi oluşturma
|
||||
|
||||
Deponun kök dizininde `main.c` adında bir dosya oluşturun ve aşağıdaki içeriği ekleyin:
|
||||
|
||||
```c
|
||||
#include "pumpkin_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
pumpkin_metadata_t get_meta(void) {
|
||||
static const char* authors[] = {"you"};
|
||||
return (pumpkin_metadata_t) {
|
||||
.name = "my-c-plugin",
|
||||
.version = "0.1.0",
|
||||
.authors = authors,
|
||||
.authors_count = 1,
|
||||
.description = "Pumpkin için basit bir C eklentisi",
|
||||
.dependencies_count = 0
|
||||
};
|
||||
}
|
||||
|
||||
void on_load(plugin_own_context_t ctx) {
|
||||
printf("C eklentisi yüklendi!\n");
|
||||
}
|
||||
|
||||
REGISTER_PUMPKIN_PLUGIN(((pumpkin_plugin_t){
|
||||
.get_metadata = get_meta,
|
||||
.on_load = on_load
|
||||
}))
|
||||
```
|
||||
|
||||
## Eklentiyi derleme
|
||||
|
||||
Eklentinizi bir WebAssembly bileşeni olarak derlemek için `wasi-sdk` kurulumunuzdaki `clang` derleyicisini kullanın.
|
||||
|
||||
`/path/to/wasi-sdk` kısmını WASI SDK'nızın gerçek yoluyla değiştirin.
|
||||
|
||||
```bash
|
||||
/path/to/wasi-sdk/bin/clang -O3 \
|
||||
-Iinclude -Isrc/gen \
|
||||
src/gen/plugin.c src/pumpkin_api.c main.c \
|
||||
-o my_plugin.wasm \
|
||||
-mexec-model=reactor
|
||||
```
|
||||
|
||||
Bu, Pumpkin sunucunuzun `plugins` klasörüne yerleştirebileceğiniz bir `my_plugin.wasm` dosyası oluşturacaktır.
|
||||
@ -7,4 +7,8 @@ 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 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 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-c)
|
||||
|
||||
64
docs/zh_cn/plugin-dev/c/quick-start.md
Normal file
64
docs/zh_cn/plugin-dev/c/quick-start.md
Normal file
@ -0,0 +1,64 @@
|
||||
# 快速入门
|
||||
|
||||
本指南将帮助您开始使用 C 语言编写 Pumpkin 服务器插件。
|
||||
|
||||
## 前提条件
|
||||
|
||||
在开始之前,请确保您已安装以下内容:
|
||||
- [wasi-sdk](https://github.com/WebAssembly/wasi-sdk/releases) (用于将 C 编译为 WASI)
|
||||
- `git` (用于克隆 API)
|
||||
|
||||
## 设置项目
|
||||
|
||||
首先,克隆带有子模块的 Pumpkin C API 存储库:
|
||||
|
||||
```bash
|
||||
git clone --recursive https://github.com/Pumpkin-MC/pumpkin-api-c.git
|
||||
cd pumpkin-api-c
|
||||
```
|
||||
|
||||
## 创建您的第一个插件
|
||||
|
||||
在存储库根目录下创建一个名为 `main.c` 的文件,并添加以下内容:
|
||||
|
||||
```c
|
||||
#include "pumpkin_api.h"
|
||||
#include <stdio.h>
|
||||
|
||||
pumpkin_metadata_t get_meta(void) {
|
||||
static const char* authors[] = {"you"};
|
||||
return (pumpkin_metadata_t) {
|
||||
.name = "my-c-plugin",
|
||||
.version = "0.1.0",
|
||||
.authors = authors,
|
||||
.authors_count = 1,
|
||||
.description = "一个简单的 Pumpkin C 插件",
|
||||
.dependencies_count = 0
|
||||
};
|
||||
}
|
||||
|
||||
void on_load(plugin_own_context_t ctx) {
|
||||
printf("C 插件已加载!\n");
|
||||
}
|
||||
|
||||
REGISTER_PUMPKIN_PLUGIN(((pumpkin_plugin_t){
|
||||
.get_metadata = get_meta,
|
||||
.on_load = on_load
|
||||
}))
|
||||
```
|
||||
|
||||
## 构建插件
|
||||
|
||||
要将插件构建为 WebAssembly 组件,请使用 `wasi-sdk` 安装中的 `clang` 编译器。
|
||||
|
||||
将 `/path/to/wasi-sdk` 替换为 WASI SDK 的实际路径。
|
||||
|
||||
```bash
|
||||
/path/to/wasi-sdk/bin/clang -O3 \
|
||||
-Iinclude -Isrc/gen \
|
||||
src/gen/plugin.c src/pumpkin_api.c main.c \
|
||||
-o my_plugin.wasm \
|
||||
-mexec-model=reactor
|
||||
```
|
||||
|
||||
这将生成一个 `my_plugin.wasm` 文件,您可以将其放在 Pumpkin 服务器的 `plugins` 文件夹中。
|
||||
@ -7,4 +7,8 @@ Pumpkin 插件 API 仍处于非常早期的开发阶段,可能随时会发生
|
||||
|
||||
Pumpkin 插件与服务器软件在很深的层次上集成,允许实现其他服务器软件无法实现的许多功能。
|
||||
|
||||
Pumpkin 插件 API 在很多方面受到 Spigot/Bukkit 插件 API 的启发,因此如果您有这些 API 的使用经验并且熟悉 Rust 开发,您应该能够相对轻松地为 Pumpkin 编写插件。 :smile:
|
||||
Pumpkin 插件 API 在很多方面受到 Spigot/Bukkit 插件 API 的启发,因此如果您有这些 API 的使用经验并且熟悉 Rust、Python 或 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-c)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user