From d4f9bb8253264c603aece5cd639ead7e9f96cf6d Mon Sep 17 00:00:00 2001 From: Alexander Medvedev Date: Wed, 29 Apr 2026 13:13:45 +0200 Subject: [PATCH] feat: C# guide --- bun.lock | 8 +- docs/.vitepress/de.ts | 10 ++ docs/.vitepress/en.ts | 10 ++ docs/.vitepress/nl.ts | 10 ++ docs/.vitepress/pt.ts | 10 ++ docs/.vitepress/tr_tr.ts | 10 ++ docs/.vitepress/zh_cn.ts | 10 ++ docs/de/plugin-dev/csharp/quick-start.md | 116 ++++++++++++++++++++ docs/de/plugin-dev/introduction.md | 3 +- docs/en/plugin-dev/csharp/quick-start.md | 116 ++++++++++++++++++++ docs/en/plugin-dev/introduction.md | 3 +- docs/nl/plugin-dev/csharp/quick-start.md | 116 ++++++++++++++++++++ docs/nl/plugin-dev/introduction.md | 3 +- docs/pt/plugin-dev/csharp/quick-start.md | 116 ++++++++++++++++++++ docs/pt/plugin-dev/introduction.md | 3 +- docs/tr_TR/plugin-dev/csharp/quick-start.md | 116 ++++++++++++++++++++ docs/tr_TR/plugin-dev/introduction.md | 3 +- docs/zh_cn/plugin-dev/csharp/quick-start.md | 116 ++++++++++++++++++++ docs/zh_cn/plugin-dev/introduction.md | 3 +- package.json | 2 +- 20 files changed, 773 insertions(+), 11 deletions(-) create mode 100644 docs/de/plugin-dev/csharp/quick-start.md create mode 100644 docs/en/plugin-dev/csharp/quick-start.md create mode 100644 docs/nl/plugin-dev/csharp/quick-start.md create mode 100644 docs/pt/plugin-dev/csharp/quick-start.md create mode 100644 docs/tr_TR/plugin-dev/csharp/quick-start.md create mode 100644 docs/zh_cn/plugin-dev/csharp/quick-start.md diff --git a/bun.lock b/bun.lock index 80f9a2d..ed09508 100644 --- a/bun.lock +++ b/bun.lock @@ -8,8 +8,8 @@ }, "devDependencies": { "@types/bun": "^1.3.12", - "vitepress": "^2.0.0-alpha.16", - "vue": "^3.6.0-beta.7", + "vitepress": "^2.0.0-alpha.17", + "vue": "^3.6.0-beta.10", }, }, }, @@ -148,7 +148,7 @@ "@shikijs/vscode-textmate": ["@shikijs/vscode-textmate@10.0.2", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="], - "@types/bun": ["@types/bun@1.3.12", "", { "dependencies": { "bun-types": "1.3.12" } }, "sha512-DBv81elK+/VSwXHDlnH3Qduw+KxkTIWi7TXkAeh24zpi5l0B2kUg9Ga3tb4nJaPcOFswflgi/yAvMVBPrxMB+A=="], + "@types/bun": ["@types/bun@1.3.13", "", { "dependencies": { "bun-types": "1.3.13" } }, "sha512-9fqXWk5YIHGGnUau9TEi+qdlTYDAnOj+xLCmSTwXfAIqXr2x4tytJb43E9uCvt09zJURKXwAtkoH4nLQfzeTXw=="], "@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="], @@ -210,7 +210,7 @@ "birpc": ["birpc@2.9.0", "", {}, "sha512-KrayHS5pBi69Xi9JmvoqrIgYGDkD6mcSe/i6YKi3w5kekCLzrX4+nawcXqrj2tIp50Kw/mT/s3p+GVK0A0sKxw=="], - "bun-types": ["bun-types@1.3.12", "", { "dependencies": { "@types/node": "*" } }, "sha512-HqOLj5PoFajAQciOMRiIZGNoKxDJSr6qigAttOX40vJuSp6DN/CxWp9s3C1Xwm4oH7ybueITwiaOcWXoYVoRkA=="], + "bun-types": ["bun-types@1.3.13", "", { "dependencies": { "@types/node": "*" } }, "sha512-QXKeHLlOLqQX9LgYaHJfzdBaV21T63HhFJnvuRCcjZiaUDpbs5ED1MgxbMra71CsryN/1dAoXuJJJwIv/2drVA=="], "ccount": ["ccount@2.0.1", "", {}, "sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg=="], diff --git a/docs/.vitepress/de.ts b/docs/.vitepress/de.ts index dd09fd9..a64dbb3 100644 --- a/docs/.vitepress/de.ts +++ b/docs/.vitepress/de.ts @@ -118,6 +118,16 @@ export const de = defineConfig({ }, ], }, + { + text: "C#", + collapsed: false, + items: [ + { + text: "Quick Start", + link: "/de/plugin-dev/csharp/quick-start", + }, + ], + }, { text: "C", collapsed: false, diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 4f78c9f..345e06e 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -116,6 +116,16 @@ export const en = defineConfig({ }, ], }, + { + text: "C#", + collapsed: false, + items: [ + { + text: "Quick Start", + link: "/plugin-dev/csharp/quick-start", + }, + ], + }, { text: "C", collapsed: false, diff --git a/docs/.vitepress/nl.ts b/docs/.vitepress/nl.ts index 3e1410b..27d52b7 100644 --- a/docs/.vitepress/nl.ts +++ b/docs/.vitepress/nl.ts @@ -99,6 +99,16 @@ export const nl = defineConfig({ }, ], }, + { + text: "C#", + collapsed: false, + items: [ + { + text: "Quick Start", + link: "/nl/plugin-dev/csharp/quick-start", + }, + ], + }, { text: "C", collapsed: false, diff --git a/docs/.vitepress/pt.ts b/docs/.vitepress/pt.ts index 6422f3a..5c19e04 100644 --- a/docs/.vitepress/pt.ts +++ b/docs/.vitepress/pt.ts @@ -99,6 +99,16 @@ export const pt = defineConfig({ }, ], }, + { + text: "C#", + collapsed: false, + items: [ + { + text: "Quick Start", + link: "/pt/plugin-dev/csharp/quick-start", + }, + ], + }, { text: "C", collapsed: false, diff --git a/docs/.vitepress/tr_tr.ts b/docs/.vitepress/tr_tr.ts index da3fb3a..675da50 100644 --- a/docs/.vitepress/tr_tr.ts +++ b/docs/.vitepress/tr_tr.ts @@ -118,6 +118,16 @@ export const trTR = defineConfig({ }, ], }, + { + text: "C#", + collapsed: false, + items: [ + { + text: "Hızlı Başlangıç", + link: "/tr_TR/plugin-dev/csharp/quick-start", + }, + ], + }, { text: "C", collapsed: false, diff --git a/docs/.vitepress/zh_cn.ts b/docs/.vitepress/zh_cn.ts index 7942f47..47a2b86 100644 --- a/docs/.vitepress/zh_cn.ts +++ b/docs/.vitepress/zh_cn.ts @@ -124,6 +124,16 @@ export const zhCN = defineConfig({ }, ], }, + { + text: "C#", + collapsed: false, + items: [ + { + text: "快速入门", + link: "/zh_cn/plugin-dev/csharp/quick-start", + }, + ], + }, { text: "C", collapsed: false, diff --git a/docs/de/plugin-dev/csharp/quick-start.md b/docs/de/plugin-dev/csharp/quick-start.md new file mode 100644 index 0000000..babf770 --- /dev/null +++ b/docs/de/plugin-dev/csharp/quick-start.md @@ -0,0 +1,116 @@ +# Schnellstart + +Diese Anleitung hilft dir beim Einstieg in die Entwicklung von Pumpkin-Server-Plugins mit C#. + +## Voraussetzungen + +Bevor du beginnst, stelle sicher, dass du Folgendes installiert hast: +- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) oder neuer. +- [WebAssembly Workload](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/webassembly-overview): Möglicherweise musst du die WASI-Workload installieren: + ```bash + dotnet workload install wasi-experimental + ``` + +## Projekt einrichten + +Erstelle zunächst ein neues Klassenbibliotheksprojekt: + +```bash +dotnet new classlib -n MyPumpkinPlugin +cd MyPumpkinPlugin +``` + +Erstelle eine `NuGet.Config`-Datei im Stammverzeichnis deines Projekts, um den experimentellen .NET-Feed einzubinden: + +```xml + + + + + + +``` + +Füge die Pumpkin API und das WebAssembly SDK hinzu: + +```bash +dotnet add package PumpkinMC.PumpkinApi +dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease +``` + +Bearbeite deine `.csproj`-Datei, um `wasi-wasm` als Ziel festzulegen und .NET 10.0 zu verwenden: + +```xml + + + + net10.0 + enable + enable + wasi-wasm + + + + + + + + +``` + +## Erstellen deines ersten Plugins + +Ersetze den Inhalt von `Class1.cs` (oder erstelle eine neue Datei `MyPlugin.cs`) durch den folgenden Code: + +```csharp +using PluginWorld; +using PluginWorld.wit.Exports.pumpkin.plugin.v0_1_0; +using PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; + +namespace MyPumpkinPlugin; + +public class MyPlugin : IPluginWorldExports, IMetadataExports +{ + public static void InitPlugin() { } + + public static void OnLoad(IContextImports.Context context) + { + ILoggingImports.Log(ILoggingImports.Level.Info, "C# Plugin geladen!"); + } + + public static void OnUnload(IContextImports.Context context) { } + + public static IEventImports.Event HandleEvent(uint eventId, IServerImports.Server server, IEventImports.Event @event) + { + return @event; + } + + public static int HandleCommand(uint commandId, ICommandImports.CommandSender sender, IServerImports.Server server, ICommandImports.ConsumedArgs args) + { + return 0; + } + + public static void HandleTask(uint handlerId, IServerImports.Server server) { } + + public static IMetadataExports.PluginMetadata Metadata() + { + return new IMetadataExports.PluginMetadata( + "my-csharp-plugin", + "0.1.0", + "Ein Beispiel-C#-Plugin.", + ["DeinName"], + [] + ); + } +} +``` + +## Plugin bauen + +Um dein Plugin in eine WebAssembly-Komponente zu kompilieren: + +```bash +dotnet build -c Release +``` + +Die kompilierte `.wasm`-Datei befindet sich in `bin/Release/net10.0/wasi-wasm/publish/`. Du kannst diese Datei in den `plugins`-Ordner deines Pumpkin-Servers legen. diff --git a/docs/de/plugin-dev/introduction.md b/docs/de/plugin-dev/introduction.md index d27d454..3e361af 100644 --- a/docs/de/plugin-dev/introduction.md +++ b/docs/de/plugin-dev/introduction.md @@ -7,9 +7,10 @@ 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 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# 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) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/en/plugin-dev/csharp/quick-start.md b/docs/en/plugin-dev/csharp/quick-start.md new file mode 100644 index 0000000..37b8e15 --- /dev/null +++ b/docs/en/plugin-dev/csharp/quick-start.md @@ -0,0 +1,116 @@ +# 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: +- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) or later. +- [WebAssembly Workload](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/webassembly-overview): You may need to install the WASI workload: + ```bash + dotnet workload install wasi-experimental + ``` + +## Setting up the project + +First, create a new class library project: + +```bash +dotnet new classlib -n MyPumpkinPlugin +cd MyPumpkinPlugin +``` + +Create a `NuGet.Config` file in your project root to include the experimental .NET feed: + +```xml + + + + + + +``` + +Add the Pumpkin API and the WebAssembly SDK: + +```bash +dotnet add package PumpkinMC.PumpkinApi +dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease +``` + +Edit your `.csproj` file to target `wasi-wasm` and use .NET 10.0: + +```xml + + + + net10.0 + enable + enable + wasi-wasm + + + + + + + + +``` + +## Creating your first plugin + +Replace the content of `Class1.cs` (or create a new file `MyPlugin.cs`) with the following code: + +```csharp +using PluginWorld; +using PluginWorld.wit.Exports.pumpkin.plugin.v0_1_0; +using PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; + +namespace MyPumpkinPlugin; + +public class MyPlugin : IPluginWorldExports, IMetadataExports +{ + public static void InitPlugin() { } + + public static void OnLoad(IContextImports.Context context) + { + ILoggingImports.Log(ILoggingImports.Level.Info, "C# plugin loaded!"); + } + + public static void OnUnload(IContextImports.Context context) { } + + public static IEventImports.Event HandleEvent(uint eventId, IServerImports.Server server, IEventImports.Event @event) + { + return @event; + } + + public static int HandleCommand(uint commandId, ICommandImports.CommandSender sender, IServerImports.Server server, ICommandImports.ConsumedArgs args) + { + return 0; + } + + public static void HandleTask(uint handlerId, IServerImports.Server server) { } + + public static IMetadataExports.PluginMetadata Metadata() + { + return new IMetadataExports.PluginMetadata( + "my-csharp-plugin", + "0.1.0", + "An example C# plugin.", + ["YourName"], + [] + ); + } +} +``` + +## Building the plugin + +To build your plugin into a WebAssembly component: + +```bash +dotnet build -c Release +``` + +The compiled `.wasm` file will be located in `bin/Release/net10.0/wasi-wasm/publish/`. You can place this file in the `plugins` folder of your Pumpkin server. diff --git a/docs/en/plugin-dev/introduction.md b/docs/en/plugin-dev/introduction.md index 029020a..fb1029b 100644 --- a/docs/en/plugin-dev/introduction.md +++ b/docs/en/plugin-dev/introduction.md @@ -6,9 +6,10 @@ 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, or C development, +so if you have previous experience with these and have experience with Rust, Python, C#, 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) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/nl/plugin-dev/csharp/quick-start.md b/docs/nl/plugin-dev/csharp/quick-start.md new file mode 100644 index 0000000..2e4e3db --- /dev/null +++ b/docs/nl/plugin-dev/csharp/quick-start.md @@ -0,0 +1,116 @@ +# Snelstart + +Deze gids helpt je op weg met het schrijven van Pumpkin server plugins met C#. + +## Vereisten + +Voordat je begint, zorg ervoor dat je het volgende hebt geïnstalleerd: +- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) of nieuwer. +- [WebAssembly Workload](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/webassembly-overview): Je moet mogelijk de WASI workload installeren: + ```bash + dotnet workload install wasi-experimental + ``` + +## Het project opzetten + +Maak eerst een nieuw class library project aan: + +```bash +dotnet new classlib -n MyPumpkinPlugin +cd MyPumpkinPlugin +``` + +Maak een `NuGet.Config` bestand aan in de hoofdmap van je project om de experimentele .NET feed toe te voegen: + +```xml + + + + + + +``` + +Voeg de Pumpkin API en de WebAssembly SDK toe: + +```bash +dotnet add package PumpkinMC.PumpkinApi +dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease +``` + +Bewerk je `.csproj` bestand om `wasi-wasm` als doel in te stellen en .NET 10.0 te gebruiken: + +```xml + + + + net10.0 + enable + enable + wasi-wasm + + + + + + + + +``` + +## Je eerste plugin maken + +Vervang de inhoud van `Class1.cs` (of maak een nieuw bestand `MyPlugin.cs`) door de volgende code: + +```csharp +using PluginWorld; +using PluginWorld.wit.Exports.pumpkin.plugin.v0_1_0; +using PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; + +namespace MyPumpkinPlugin; + +public class MyPlugin : IPluginWorldExports, IMetadataExports +{ + public static void InitPlugin() { } + + public static void OnLoad(IContextImports.Context context) + { + ILoggingImports.Log(ILoggingImports.Level.Info, "C# plugin geladen!"); + } + + public static void OnUnload(IContextImports.Context context) { } + + public static IEventImports.Event HandleEvent(uint eventId, IServerImports.Server server, IEventImports.Event @event) + { + return @event; + } + + public static int HandleCommand(uint commandId, ICommandImports.CommandSender sender, IServerImports.Server server, ICommandImports.ConsumedArgs args) + { + return 0; + } + + public static void HandleTask(uint handlerId, IServerImports.Server server) { } + + public static IMetadataExports.PluginMetadata Metadata() + { + return new IMetadataExports.PluginMetadata( + "my-csharp-plugin", + "0.1.0", + "Een voorbeeld C# plugin.", + ["JouwNaam"], + [] + ); + } +} +``` + +## De plugin bouwen + +Om je plugin te compileren naar een WebAssembly component: + +```bash +dotnet build -c Release +``` + +Het gecompileerde `.wasm` bestand bevindt zich in `bin/Release/net10.0/wasi-wasm/publish/`. Je kunt dit bestand in de `plugins` map van je Pumpkin server plaatsen. diff --git a/docs/nl/plugin-dev/introduction.md b/docs/nl/plugin-dev/introduction.md index 72ded9a..3231db1 100644 --- a/docs/nl/plugin-dev/introduction.md +++ b/docs/nl/plugin-dev/introduction.md @@ -6,9 +6,10 @@ 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 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# 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) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/pt/plugin-dev/csharp/quick-start.md b/docs/pt/plugin-dev/csharp/quick-start.md new file mode 100644 index 0000000..ff7f880 --- /dev/null +++ b/docs/pt/plugin-dev/csharp/quick-start.md @@ -0,0 +1,116 @@ +# 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: +- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) ou superior. +- [WebAssembly Workload](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/webassembly-overview): Você pode precisar instalar o workload WASI: + ```bash + dotnet workload install wasi-experimental + ``` + +## Configurando o projeto + +Primeiro, crie um novo projeto de biblioteca de classes: + +```bash +dotnet new classlib -n MyPumpkinPlugin +cd MyPumpkinPlugin +``` + +Crie um arquivo `NuGet.Config` na raiz do seu projeto para incluir o feed experimental do .NET: + +```xml + + + + + + +``` + +Adicione a API do Pumpkin e o SDK do WebAssembly: + +```bash +dotnet add package PumpkinMC.PumpkinApi +dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease +``` + +Edite seu arquivo `.csproj` para visar `wasi-wasm` e usar o .NET 10.0: + +```xml + + + + net10.0 + enable + enable + wasi-wasm + + + + + + + + +``` + +## Criando seu primeiro plugin + +Substitua o conteúdo de `Class1.cs` (ou crie um novo arquivo `MyPlugin.cs`) pelo seguinte código: + +```csharp +using PluginWorld; +using PluginWorld.wit.Exports.pumpkin.plugin.v0_1_0; +using PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; + +namespace MyPumpkinPlugin; + +public class MyPlugin : IPluginWorldExports, IMetadataExports +{ + public static void InitPlugin() { } + + public static void OnLoad(IContextImports.Context context) + { + ILoggingImports.Log(ILoggingImports.Level.Info, "Plugin C# carregado!"); + } + + public static void OnUnload(IContextImports.Context context) { } + + public static IEventImports.Event HandleEvent(uint eventId, IServerImports.Server server, IEventImports.Event @event) + { + return @event; + } + + public static int HandleCommand(uint commandId, ICommandImports.CommandSender sender, IServerImports.Server server, ICommandImports.ConsumedArgs args) + { + return 0; + } + + public static void HandleTask(uint handlerId, IServerImports.Server server) { } + + public static IMetadataExports.PluginMetadata Metadata() + { + return new IMetadataExports.PluginMetadata( + "my-csharp-plugin", + "0.1.0", + "Um exemplo de plugin C#.", + ["SeuNome"], + [] + ); + } +} +``` + +## Compilando o plugin + +Para compilar seu plugin em um componente WebAssembly: + +```bash +dotnet build -c Release +``` + +O arquivo `.wasm` compilado estará localizado em `bin/Release/net10.0/wasi-wasm/publish/`. Você pode colocar este arquivo na pasta `plugins` do seu servidor Pumpkin. diff --git a/docs/pt/plugin-dev/introduction.md b/docs/pt/plugin-dev/introduction.md index 2f5832c..94b2d7b 100644 --- a/docs/pt/plugin-dev/introduction.md +++ b/docs/pt/plugin-dev/introduction.md @@ -7,8 +7,9 @@ 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 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# 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) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/tr_TR/plugin-dev/csharp/quick-start.md b/docs/tr_TR/plugin-dev/csharp/quick-start.md new file mode 100644 index 0000000..4c5cf32 --- /dev/null +++ b/docs/tr_TR/plugin-dev/csharp/quick-start.md @@ -0,0 +1,116 @@ +# Hızlı Başlangıç + +Bu rehber, C# kullanarak Pumpkin sunucu eklentileri yazmaya başlamanıza yardımcı olacaktır. + +## Ön Koşullar + +Başlamadan önce aşağıdakilerin kurulu olduğundan emin olun: +- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) veya daha yenisi. +- [WebAssembly Workload](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/webassembly-overview): WASI workload'unu kurmanız gerekebilir: + ```bash + dotnet workload install wasi-experimental + ``` + +## Projeyi Kurma + +İlk olarak, yeni bir sınıf kütüphanesi (class library) projesi oluşturun: + +```bash +dotnet new classlib -n MyPumpkinPlugin +cd MyPumpkinPlugin +``` + +Deneysel .NET beslemesini (feed) dahil etmek için projenizin kök dizininde bir `NuGet.Config` dosyası oluşturun: + +```xml + + + + + + +``` + +Pumpkin API'sini ve WebAssembly SDK'sını ekleyin: + +```bash +dotnet add package PumpkinMC.PumpkinApi +dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease +``` + +`.csproj` dosyanızı `wasi-wasm` hedefleyecek ve .NET 10.0 kullanacak şekilde düzenleyin: + +```xml + + + + net10.0 + enable + enable + wasi-wasm + + + + + + + + +``` + +## İlk Eklentinizi Oluşturma + +`Class1.cs` içeriğini (veya yeni bir `MyPlugin.cs` dosyası oluşturarak) aşağıdaki kodla değiştirin: + +```csharp +using PluginWorld; +using PluginWorld.wit.Exports.pumpkin.plugin.v0_1_0; +using PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; + +namespace MyPumpkinPlugin; + +public class MyPlugin : IPluginWorldExports, IMetadataExports +{ + public static void InitPlugin() { } + + public static void OnLoad(IContextImports.Context context) + { + ILoggingImports.Log(ILoggingImports.Level.Info, "C# eklentisi yüklendi!"); + } + + public static void OnUnload(IContextImports.Context context) { } + + public static IEventImports.Event HandleEvent(uint eventId, IServerImports.Server server, IEventImports.Event @event) + { + return @event; + } + + public static int HandleCommand(uint commandId, ICommandImports.CommandSender sender, IServerImports.Server server, ICommandImports.ConsumedArgs args) + { + return 0; + } + + public static void HandleTask(uint handlerId, IServerImports.Server server) { } + + public static IMetadataExports.PluginMetadata Metadata() + { + return new IMetadataExports.PluginMetadata( + "my-csharp-plugin", + "0.1.0", + "Örnek bir C# eklentisi.", + ["Adınız"], + [] + ); + } +} +``` + +## Eklentiyi Derleme + +Eklentinizi bir WebAssembly bileşeni olarak derlemek için: + +```bash +dotnet build -c Release +``` + +Derlenmiş `.wasm` dosyası `bin/Release/net10.0/wasi-wasm/publish/` dizininde bulunacaktır. Bu dosyayı Pumpkin sunucunuzun `plugins` klasörüne yerleştirebilirsiniz. diff --git a/docs/tr_TR/plugin-dev/introduction.md b/docs/tr_TR/plugin-dev/introduction.md index 5546658..a080069 100644 --- a/docs/tr_TR/plugin-dev/introduction.md +++ b/docs/tr_TR/plugin-dev/introduction.md @@ -7,8 +7,9 @@ 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 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# 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) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/docs/zh_cn/plugin-dev/csharp/quick-start.md b/docs/zh_cn/plugin-dev/csharp/quick-start.md new file mode 100644 index 0000000..6a52b70 --- /dev/null +++ b/docs/zh_cn/plugin-dev/csharp/quick-start.md @@ -0,0 +1,116 @@ +# 快速入门 + +本指南将帮助您开始使用 C# 编写 Pumpkin 服务器插件。 + +## 先决条件 + +在开始之前,请确保您已安装以下内容: +- [.NET 10.0](https://dotnet.microsoft.com/download/dotnet/10.0) 或更高版本。 +- [WebAssembly 工作负载](https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/webassembly-overview):您可能需要安装 WASI 工作负载: + ```bash + dotnet workload install wasi-experimental + ``` + +## 设置项目 + +首先,创建一个新的类库项目: + +```bash +dotnet new classlib -n MyPumpkinPlugin +cd MyPumpkinPlugin +``` + +在项目根目录下创建一个 `NuGet.Config` 文件,以包含实验性的 .NET 订阅源: + +```xml + + + + + + +``` + +添加 Pumpkin API 和 WebAssembly SDK: + +```bash +dotnet add package PumpkinMC.PumpkinApi +dotnet add package ByteCodeAlliance.Componentize.DotNet.Wasm.SDK --prerelease +``` + +编辑您的 `.csproj` 文件以针对 `wasi-wasm` 并使用 .NET 10.0: + +```xml + + + + net10.0 + enable + enable + wasi-wasm + + + + + + + + +``` + +## 创建您的第一个插件 + +将 `Class1.cs` 的内容(或创建一个新文件 `MyPlugin.cs`)替换为以下代码: + +```csharp +using PluginWorld; +using PluginWorld.wit.Exports.pumpkin.plugin.v0_1_0; +using PluginWorld.wit.Imports.pumpkin.plugin.v0_1_0; + +namespace MyPumpkinPlugin; + +public class MyPlugin : IPluginWorldExports, IMetadataExports +{ + public static void InitPlugin() { } + + public static void OnLoad(IContextImports.Context context) + { + ILoggingImports.Log(ILoggingImports.Level.Info, "C# 插件已加载!"); + } + + public static void OnUnload(IContextImports.Context context) { } + + public static IEventImports.Event HandleEvent(uint eventId, IServerImports.Server server, IEventImports.Event @event) + { + return @event; + } + + public static int HandleCommand(uint commandId, ICommandImports.CommandSender sender, IServerImports.Server server, ICommandImports.ConsumedArgs args) + { + return 0; + } + + public static void HandleTask(uint handlerId, IServerImports.Server server) { } + + public static IMetadataExports.PluginMetadata Metadata() + { + return new IMetadataExports.PluginMetadata( + "my-csharp-plugin", + "0.1.0", + "一个示例 C# 插件。", + ["您的名字"], + [] + ); + } +} +``` + +## 构建插件 + +要将插件构建为 WebAssembly 组件: + +```bash +dotnet build -c Release +``` + +构建后的 `.wasm` 文件将位于 `bin/Release/net10.0/wasi-wasm/publish/` 目录中。您可以将此文件放置在 Pumpkin 服务器的 `plugins` 文件夹中。 diff --git a/docs/zh_cn/plugin-dev/introduction.md b/docs/zh_cn/plugin-dev/introduction.md index aff40cd..c5aa618 100644 --- a/docs/zh_cn/plugin-dev/introduction.md +++ b/docs/zh_cn/plugin-dev/introduction.md @@ -7,8 +7,9 @@ Pumpkin 插件 API 仍处于非常早期的开发阶段,可能随时会发生 Pumpkin 插件与服务器软件在很深的层次上集成,允许实现其他服务器软件无法实现的许多功能。 -Pumpkin 插件 API 在很多方面受到 Spigot/Bukkit 插件 API 的启发,因此如果您有这些 API 的使用经验并且熟悉 Rust、Python 或 C 开发,您应该能够相对轻松地为 Pumpkin 编写插件。 :smile: +Pumpkin 插件 API 在很多方面受到 Spigot/Bukkit 插件 API 的启发,因此如果您有这些 API 的使用经验并且熟悉 Rust、Python、C# 或 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) * [C API](https://github.com/Pumpkin-MC/pumpkin-api-c) diff --git a/package.json b/package.json index 80a01fa..ac9a5f2 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "preview": "vitepress preview docs" }, "devDependencies": { - "@types/bun": "^1.3.12", + "@types/bun": "^1.3.13", "vitepress": "^2.0.0-alpha.17", "vue": "^3.6.0-beta.10" },