feat: C# guide
This commit is contained in:
parent
92801aa3a0
commit
d4f9bb8253
8
bun.lock
8
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=="],
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
116
docs/de/plugin-dev/csharp/quick-start.md
Normal file
116
docs/de/plugin-dev/csharp/quick-start.md
Normal file
@ -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
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
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
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="*-*" />
|
||||
<PackageReference Include="PumpkinMC.PumpkinApi" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
```
|
||||
|
||||
## 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.
|
||||
@ -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)
|
||||
|
||||
|
||||
116
docs/en/plugin-dev/csharp/quick-start.md
Normal file
116
docs/en/plugin-dev/csharp/quick-start.md
Normal file
@ -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
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
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
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="*-*" />
|
||||
<PackageReference Include="PumpkinMC.PumpkinApi" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
```
|
||||
|
||||
## 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.
|
||||
@ -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)
|
||||
|
||||
116
docs/nl/plugin-dev/csharp/quick-start.md
Normal file
116
docs/nl/plugin-dev/csharp/quick-start.md
Normal file
@ -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
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
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
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="*-*" />
|
||||
<PackageReference Include="PumpkinMC.PumpkinApi" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
```
|
||||
|
||||
## 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.
|
||||
@ -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)
|
||||
|
||||
|
||||
116
docs/pt/plugin-dev/csharp/quick-start.md
Normal file
116
docs/pt/plugin-dev/csharp/quick-start.md
Normal file
@ -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
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
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
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="*-*" />
|
||||
<PackageReference Include="PumpkinMC.PumpkinApi" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
```
|
||||
|
||||
## 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.
|
||||
@ -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)
|
||||
|
||||
116
docs/tr_TR/plugin-dev/csharp/quick-start.md
Normal file
116
docs/tr_TR/plugin-dev/csharp/quick-start.md
Normal file
@ -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
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
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
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="*-*" />
|
||||
<PackageReference Include="PumpkinMC.PumpkinApi" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
```
|
||||
|
||||
## İ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.
|
||||
@ -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)
|
||||
|
||||
116
docs/zh_cn/plugin-dev/csharp/quick-start.md
Normal file
116
docs/zh_cn/plugin-dev/csharp/quick-start.md
Normal file
@ -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
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="dotnet-experimental" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-experimental/nuget/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
添加 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
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ByteCodeAlliance.Componentize.DotNet.Wasm.SDK" Version="*-*" />
|
||||
<PackageReference Include="PumpkinMC.PumpkinApi" Version="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
```
|
||||
|
||||
## 创建您的第一个插件
|
||||
|
||||
将 `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` 文件夹中。
|
||||
@ -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)
|
||||
|
||||
@ -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"
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user