Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/de/plugin-dev/rust/basic-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Auch ein einfaches Plugin hat unter der Haube einiges an Komplexität. Um die Pl

:::code-group

```rs:line-numbers [lib.rs]
```rust:line-numbers [lib.rs]
use pumpkin_api_macros::plugin_impl;

#[plugin_impl]
Expand Down Expand Up @@ -82,7 +82,7 @@ Um diese Methoden zu vereinfachen, stellt `pumpkin-api-macros` ein weiteres Macr

:::code-group

```rs [lib.rs]
```rust [lib.rs]
use std::sync::Arc; // [!code ++:4]

use pumpkin_api_macros::{plugin_impl, plugin_method};
Expand Down Expand Up @@ -120,22 +120,22 @@ Die Methode erhält eine veränderbare Referenz auf das Plugin‑Objekt (hier `M

### Methoden im `Context`‑Objekt (Auszug)

```rs
```rust
fn get_data_folder() -> String
```
Gibt den Pfad zum plugin‑spezifischen Datenordner zurück.

```rs
```rust
async fn get_player_by_name(player_name: String) -> Option<Arc<Player>>
```
Gibt, falls ein Spieler online ist, eine Referenz auf diesen zurück.

```rs
```rust
async fn register_command(tree: CommandTree, permission: PermissionLvl)
```
Registriert einen neuen Befehls‑Handler mit minimal erforderlichem Berechtigungslevel.

```rs
```rust
async fn register_event(handler: Arc<H>, priority: EventPriority, blocking: bool)
```
Registriert einen Event‑Handler mit Priorität und Angabe, ob er blockierend ist.
Expand All @@ -146,7 +146,7 @@ In `on_load` initialisieren wir das Pumpkin‑Logging und geben eine Info‑Nach

:::code-group

```rs [lib.rs]
```rust [lib.rs]
#[plugin_method]
async fn on_load(&mut self, server: Arc<Context>) -> Result<(), String> {
server.init_log(); // [!code ++:3]
Expand Down
12 changes: 6 additions & 6 deletions docs/de/plugin-dev/rust/command/rock-paper-scissors.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Wir möchten außerdem [ploxxxy](https://github.com/ploxxxy) für das ursprüngl

Jeder Befehl in Pumpkin wird als Struktur definiert, die das Trait `CommandExecutor` implementiert. Dieses Trait verlangt die Implementierung einer Methode `execute`, welche den Sender, den Server und die konsumierten Argumente entgegennimmt und `Result<(), CommandError>` zurückgibt. Definieren wir diese Struktur jetzt:

```rs
```rust
use pumpkin::{
command::{ // [!code ++:4]
args::ConsumedArgs, dispatcher::CommandError, tree::builder::literal, tree::CommandTree,
Expand Down Expand Up @@ -44,7 +44,7 @@ Dieser Code definiert eine leere Struktur `RockPaperScissorsExecutor`, die das T

Um uns die Logik zu vereinfachen, definieren wir zwei Enums für mögliche Spielzüge und Spielausgänge sowie Hilfsfunktionen zur Zufallsauswahl und zur Auswertung des Ergebnisses. Füge diese deinem Plugin hinzu:

```rs
```rust
use rand::{rng, Rng};

#[derive(PartialEq, Debug, Clone, Copy)]
Expand Down Expand Up @@ -84,7 +84,7 @@ fn get_random_choice() -> Choice {

Nun müssen wir die Struktur `RockPaperScissorsExecutor` anpassen, damit sie eine `Choice` annimmt, und die Spiellogik vorbereiten:

```rs
```rust
struct RockPaperScissorsExecutor(Choice); // [!code ++]
struct RockPaperScissorsExecutor; // [!code --]

Expand Down Expand Up @@ -112,7 +112,7 @@ Nun implementieren wir die eigentliche Spiel-Logik und zeigen das Ergebnis an de

Zuerst zeigen wir dem Spieler seine Wahl sowie die Wahl des Servers. Füge diesen Code hinzu:

```rs
```rust
impl CommandExecutor for RockPaperScissorsExecutor {
fn execute<'a>(
&self,
Expand Down Expand Up @@ -148,7 +148,7 @@ impl CommandExecutor for RockPaperScissorsExecutor {

Als Nächstes berechnen wir das Ergebnis und zeigen es dem Spieler:

```rs
```rust
impl CommandExecutor for RockPaperScissorsExecutor {
fn execute<'a>(
&self,
Expand Down Expand Up @@ -196,7 +196,7 @@ Der Baum wird über `CommandTree::new()` initialisiert. Diese Funktion nimmt zwe

Für Schere‑Stein‑Papier erstellen wir drei getrennte Äste – jeweils ein `literal()` für die Spielerwahl. Danach registrieren wir den Baum mit einer `PermissionLvl` von `Zero`, sodass jeder den Befehl ausführen kann. Ergänze folgenden Code in deiner `on_load()` Methode:

```rs
```rust
use pumpkin_util::PermissionLvl; // [!code ++]

const NAMES: [&str; 2] = ["rps", "rockpaperscissors"]; // [!code ++:2]
Expand Down
4 changes: 2 additions & 2 deletions docs/de/plugin-dev/rust/join-event.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Um die Willkommensnachricht beim Join zu ändern, wählen wir ein blockierendes
Füge folgenden Code oberhalb von `on_load` ein:
:::code-group

```rs [lib.rs]
```rust [lib.rs]
// [!code ++:7]
use pumpkin_api_macros::with_runtime;
use pumpkin::{
Expand Down Expand Up @@ -82,7 +82,7 @@ impl EventHandler<PlayerJoinEvent> for MyJoinHandler {
Nachdem wir den Ereignishandler geschrieben haben, müssen wir dem Plugin mitteilen, dass es ihn verwenden soll. Dies erreichen wir durch Hinzufügen einer einzigen Zeile zur `on_load`-Methode:
:::code-group

```rs [lib.rs]
```rust [lib.rs]
use pumpkin::{
plugin::{player::player_join::PlayerJoinEvent, Context, EventHandler, EventPriority}, // [!code ++]
server::Server,
Expand Down
8 changes: 4 additions & 4 deletions docs/en/plugin-dev/rust/basic-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ we will use the `pumpkin-plugin-api` crate to create a basic empty plugin.

:::code-group

```rs:line-numbers [lib.rs]
```rust:line-numbers [lib.rs]
use pumpkin_plugin_api::{Context, Plugin, PluginMetadata};
use tracing::*;

Expand Down Expand Up @@ -88,19 +88,19 @@ hello-pumpkin-wasm

## Methods implemented on the `Context` object

```rs
```rust
fn get_server(&self) -> Server
```

Returns an instance of the server.

```rs
```rust
fn register_command(&self, command: Command, permission: &str)
```

Registers a new command handler, with the permission that is for the command.

```rs
```rust
fn register_event_handler<E, H>(&self, handler: H, event_priority: EventPriority, blocking: bool) -> Result<u32>
```

Expand Down
12 changes: 6 additions & 6 deletions docs/en/plugin-dev/rust/command/rock-paper-scissors.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This trait requires the implementation of a `handle` method, which takes the sen
and consumed arguments as parameters, and returns a `-> Result<(), CommandError>`. Let's
define this structure now:

```rs
```rust
use pumpkin_plugin_api::{
Server,
command::{CommandError, CommandSender, ConsumedArgs},
Expand Down Expand Up @@ -57,7 +57,7 @@ To make our lives easier, we will also define a couple of enums to represent the
choices and outcomes of the game, as well as well as a couple functions to generate random
choices and check the outcome. Add these to your plugin's code.

```rs
```rust
use rand::{rng, Rng};

#[derive(PartialEq, Debug, Clone, Copy)]
Expand Down Expand Up @@ -98,7 +98,7 @@ fn get_random_choice() -> Choice {
Now we need to modify the `RockPaperScissorsExecutor` struct to accept a `Choice` parameter
and implement the game logic.

```rs
```rust
struct RockPaperScissorsExecutor(Choice); // [!code ++]
struct RockPaperScissorsExecutor; // [!code --]

Expand Down Expand Up @@ -126,7 +126,7 @@ players.

First we will show the player their and the computer's choice. Add this code to your plugin:

```rs
```rust
impl CommandHandler for RockPaperScissorsExecutor {
fn handle(
&self,
Expand All @@ -153,7 +153,7 @@ impl CommandHandler for RockPaperScissorsExecutor {

Next we can compute the game outcome and show it to the player. Add this code to your plugin:

```rs
```rust
impl CommandHandler for RockPaperScissorsExecutor {
fn handle(
&self,
Expand Down Expand Up @@ -209,7 +209,7 @@ leaf node for the player's choice. We will also register the command tree with t
with a `permission` of `hello-pumpkin:command.rockpaperscisors` which will allow anyone with that
permission to execute the command. Add the following code to your `on_load()` method:

```rs
```rust
struct HelloPlugin;
impl Plugin for HelloPlugin {
fn new() -> Self {
Expand Down
4 changes: 2 additions & 2 deletions docs/en/plugin-dev/rust/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Since our main aim here is to change the welcome message that the player sees wh

:::code-group

```rs [lib.rs]
```rust [lib.rs]
// [!code ++:20]
use pumpkin_plugin_api::{
Context, Plugin, PluginMetadata, Server,
Expand Down Expand Up @@ -77,7 +77,7 @@ impl EventHandler<PlayerJoinEvent> for MyJoinHandler {
Now that we have written the event handler, we need to tell the plugin to use it. We can do that by adding a single line into the `on_load` method:
:::code-group

```rs [lib.rs]
```rust [lib.rs]
struct HelloPlugin;
impl Plugin for HelloPlugin {
fn new() -> Self {
Expand Down
Loading
Loading