chore: some "refinements"
This commit is contained in:
parent
59128ad3ad
commit
3f16300e07
@ -102,7 +102,21 @@ export const de = defineConfig({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Python",
|
text: "Python",
|
||||||
link: "/de/plugin-dev/python",
|
collapsed: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: "Quick Start",
|
||||||
|
link: "/de/plugin-dev/python/quick-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Basic Logic",
|
||||||
|
link: "/de/plugin-dev/python/basic-logic",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Events",
|
||||||
|
link: "/de/plugin-dev/python/events",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -100,7 +100,21 @@ export const en = defineConfig({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Python",
|
text: "Python",
|
||||||
link: "/plugin-dev/python",
|
collapsed: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: "Quick Start",
|
||||||
|
link: "/plugin-dev/python/quick-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Basic Logic",
|
||||||
|
link: "/plugin-dev/python/basic-logic",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Events",
|
||||||
|
link: "/plugin-dev/python/events",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -83,7 +83,21 @@ export const nl = defineConfig({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Python",
|
text: "Python",
|
||||||
link: "/nl/plugin-dev/python",
|
collapsed: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: "Quick Start",
|
||||||
|
link: "/nl/plugin-dev/python/quick-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Basic Logic",
|
||||||
|
link: "/nl/plugin-dev/python/basic-logic",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Events",
|
||||||
|
link: "/nl/plugin-dev/python/events",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -83,7 +83,21 @@ export const pt = defineConfig({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Python",
|
text: "Python",
|
||||||
link: "/pt/plugin-dev/python",
|
collapsed: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: "Quick Start",
|
||||||
|
link: "/pt/plugin-dev/python/quick-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Basic Logic",
|
||||||
|
link: "/pt/plugin-dev/python/basic-logic",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Events",
|
||||||
|
link: "/pt/plugin-dev/python/events",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -102,7 +102,21 @@ export const trTR = defineConfig({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Python",
|
text: "Python",
|
||||||
link: "/tr_TR/plugin-dev/python",
|
collapsed: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: "Quick Start",
|
||||||
|
link: "/tr_TR/plugin-dev/python/quick-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Basic Logic",
|
||||||
|
link: "/tr_TR/plugin-dev/python/basic-logic",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Events",
|
||||||
|
link: "/tr_TR/plugin-dev/python/events",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@ -108,7 +108,21 @@ export const zhCN = defineConfig({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Python",
|
text: "Python",
|
||||||
link: "/zh_cn/plugin-dev/python",
|
collapsed: false,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: "Quick Start",
|
||||||
|
link: "/zh_cn/plugin-dev/python/quick-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Basic Logic",
|
||||||
|
link: "/zh_cn/plugin-dev/python/basic-logic",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Events",
|
||||||
|
link: "/zh_cn/plugin-dev/python/events",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
38
docs/de/plugin-dev/python/basic-logic.md
Normal file
38
docs/de/plugin-dev/python/basic-logic.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Basic Logic
|
||||||
|
|
||||||
|
This section covers the basic structure of a Pumpkin plugin in Python.
|
||||||
|
|
||||||
|
## Plugin Class
|
||||||
|
|
||||||
|
Every Python plugin must inherit from the `Plugin` class. This class provides the base structure and methods needed for the server to interact with your plugin.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import Plugin, PluginMetadata, context
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
# Define plugin metadata here
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is loaded
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_unload(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is unloaded
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The `metadata` method must return a `PluginMetadata` object, which contains information about your plugin.
|
||||||
|
|
||||||
|
- `name`: The name of your plugin.
|
||||||
|
- `version`: The version of your plugin.
|
||||||
|
- `authors`: A list of authors.
|
||||||
|
- `description`: A short description of what your plugin does.
|
||||||
|
|
||||||
|
## Loading and Unloading
|
||||||
|
|
||||||
|
- `on_load`: This method is called when the server loads your plugin. You should use this to register events, commands, and perform any initialization.
|
||||||
|
- `on_unload`: This method is called when the server unloads your plugin. Use this for cleanup if necessary.
|
||||||
30
docs/de/plugin-dev/python/events.md
Normal file
30
docs/de/plugin-dev/python/events.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Events
|
||||||
|
|
||||||
|
Events allow your plugin to respond to actions occurring on the server, such as players joining or messages being sent.
|
||||||
|
|
||||||
|
## Registering an Event
|
||||||
|
|
||||||
|
You can register an event handler in the `on_load` method of your plugin using `self.register_event`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Handlers
|
||||||
|
|
||||||
|
An event handler is a method that receives the server instance and the event data. It should return the (possibly modified) event data.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Types
|
||||||
|
|
||||||
|
The `event.EventType` enum contains all available events. Some common events include:
|
||||||
|
|
||||||
|
- `PLAYER_JOIN_EVENT`
|
||||||
|
- `PLAYER_QUIT_EVENT`
|
||||||
|
- `PLAYER_CHAT_EVENT`
|
||||||
@ -1,6 +1,18 @@
|
|||||||
# Python Plugin Development
|
# Quick Start
|
||||||
|
|
||||||
Pumpkin supports writing plugins in Python. Below is a basic example of a Python plugin.
|
This guide will help you get started with writing Pumpkin server plugins using Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
First, you need to install the `pumpkin-api-py` library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pumpkin-api-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating your first plugin
|
||||||
|
|
||||||
|
Create a file named `main.py` and add the following content:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pumpkin_api import (
|
from pumpkin_api import (
|
||||||
@ -29,3 +41,13 @@ class MyPlugin(Plugin):
|
|||||||
|
|
||||||
register_plugin(MyPlugin)
|
register_plugin(MyPlugin)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
Build your plugin into a WebAssembly component using the provided build tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pumpkin-api-build main -o my_plugin.wasm
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||||
38
docs/en/plugin-dev/python/basic-logic.md
Normal file
38
docs/en/plugin-dev/python/basic-logic.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Basic Logic
|
||||||
|
|
||||||
|
This section covers the basic structure of a Pumpkin plugin in Python.
|
||||||
|
|
||||||
|
## Plugin Class
|
||||||
|
|
||||||
|
Every Python plugin must inherit from the `Plugin` class. This class provides the base structure and methods needed for the server to interact with your plugin.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import Plugin, PluginMetadata, context
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
# Define plugin metadata here
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is loaded
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_unload(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is unloaded
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The `metadata` method must return a `PluginMetadata` object, which contains information about your plugin.
|
||||||
|
|
||||||
|
- `name`: The name of your plugin.
|
||||||
|
- `version`: The version of your plugin.
|
||||||
|
- `authors`: A list of authors.
|
||||||
|
- `description`: A short description of what your plugin does.
|
||||||
|
|
||||||
|
## Loading and Unloading
|
||||||
|
|
||||||
|
- `on_load`: This method is called when the server loads your plugin. You should use this to register events, commands, and perform any initialization.
|
||||||
|
- `on_unload`: This method is called when the server unloads your plugin. Use this for cleanup if necessary.
|
||||||
30
docs/en/plugin-dev/python/events.md
Normal file
30
docs/en/plugin-dev/python/events.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Events
|
||||||
|
|
||||||
|
Events allow your plugin to respond to actions occurring on the server, such as players joining or messages being sent.
|
||||||
|
|
||||||
|
## Registering an Event
|
||||||
|
|
||||||
|
You can register an event handler in the `on_load` method of your plugin using `self.register_event`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Handlers
|
||||||
|
|
||||||
|
An event handler is a method that receives the server instance and the event data. It should return the (possibly modified) event data.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Types
|
||||||
|
|
||||||
|
The `event.EventType` enum contains all available events. Some common events include:
|
||||||
|
|
||||||
|
- `PLAYER_JOIN_EVENT`
|
||||||
|
- `PLAYER_QUIT_EVENT`
|
||||||
|
- `PLAYER_CHAT_EVENT`
|
||||||
@ -1,6 +1,18 @@
|
|||||||
# Python Plugin Development
|
# Quick Start
|
||||||
|
|
||||||
Pumpkin supports writing plugins in Python. Below is a basic example of a Python plugin.
|
This guide will help you get started with writing Pumpkin server plugins using Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
First, you need to install the `pumpkin-api-py` library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pumpkin-api-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating your first plugin
|
||||||
|
|
||||||
|
Create a file named `main.py` and add the following content:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pumpkin_api import (
|
from pumpkin_api import (
|
||||||
@ -29,3 +41,13 @@ class MyPlugin(Plugin):
|
|||||||
|
|
||||||
register_plugin(MyPlugin)
|
register_plugin(MyPlugin)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
Build your plugin into a WebAssembly component using the provided build tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pumpkin-api-build main -o my_plugin.wasm
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||||
38
docs/nl/plugin-dev/python/basic-logic.md
Normal file
38
docs/nl/plugin-dev/python/basic-logic.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Basic Logic
|
||||||
|
|
||||||
|
This section covers the basic structure of a Pumpkin plugin in Python.
|
||||||
|
|
||||||
|
## Plugin Class
|
||||||
|
|
||||||
|
Every Python plugin must inherit from the `Plugin` class. This class provides the base structure and methods needed for the server to interact with your plugin.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import Plugin, PluginMetadata, context
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
# Define plugin metadata here
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is loaded
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_unload(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is unloaded
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The `metadata` method must return a `PluginMetadata` object, which contains information about your plugin.
|
||||||
|
|
||||||
|
- `name`: The name of your plugin.
|
||||||
|
- `version`: The version of your plugin.
|
||||||
|
- `authors`: A list of authors.
|
||||||
|
- `description`: A short description of what your plugin does.
|
||||||
|
|
||||||
|
## Loading and Unloading
|
||||||
|
|
||||||
|
- `on_load`: This method is called when the server loads your plugin. You should use this to register events, commands, and perform any initialization.
|
||||||
|
- `on_unload`: This method is called when the server unloads your plugin. Use this for cleanup if necessary.
|
||||||
30
docs/nl/plugin-dev/python/events.md
Normal file
30
docs/nl/plugin-dev/python/events.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Events
|
||||||
|
|
||||||
|
Events allow your plugin to respond to actions occurring on the server, such as players joining or messages being sent.
|
||||||
|
|
||||||
|
## Registering an Event
|
||||||
|
|
||||||
|
You can register an event handler in the `on_load` method of your plugin using `self.register_event`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Handlers
|
||||||
|
|
||||||
|
An event handler is a method that receives the server instance and the event data. It should return the (possibly modified) event data.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Types
|
||||||
|
|
||||||
|
The `event.EventType` enum contains all available events. Some common events include:
|
||||||
|
|
||||||
|
- `PLAYER_JOIN_EVENT`
|
||||||
|
- `PLAYER_QUIT_EVENT`
|
||||||
|
- `PLAYER_CHAT_EVENT`
|
||||||
@ -1,6 +1,18 @@
|
|||||||
# Python Plugin Development
|
# Quick Start
|
||||||
|
|
||||||
Pumpkin supports writing plugins in Python. Below is a basic example of a Python plugin.
|
This guide will help you get started with writing Pumpkin server plugins using Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
First, you need to install the `pumpkin-api-py` library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pumpkin-api-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating your first plugin
|
||||||
|
|
||||||
|
Create a file named `main.py` and add the following content:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pumpkin_api import (
|
from pumpkin_api import (
|
||||||
@ -29,3 +41,13 @@ class MyPlugin(Plugin):
|
|||||||
|
|
||||||
register_plugin(MyPlugin)
|
register_plugin(MyPlugin)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
Build your plugin into a WebAssembly component using the provided build tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pumpkin-api-build main -o my_plugin.wasm
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||||
38
docs/pt/plugin-dev/python/basic-logic.md
Normal file
38
docs/pt/plugin-dev/python/basic-logic.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Basic Logic
|
||||||
|
|
||||||
|
This section covers the basic structure of a Pumpkin plugin in Python.
|
||||||
|
|
||||||
|
## Plugin Class
|
||||||
|
|
||||||
|
Every Python plugin must inherit from the `Plugin` class. This class provides the base structure and methods needed for the server to interact with your plugin.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import Plugin, PluginMetadata, context
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
# Define plugin metadata here
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is loaded
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_unload(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is unloaded
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The `metadata` method must return a `PluginMetadata` object, which contains information about your plugin.
|
||||||
|
|
||||||
|
- `name`: The name of your plugin.
|
||||||
|
- `version`: The version of your plugin.
|
||||||
|
- `authors`: A list of authors.
|
||||||
|
- `description`: A short description of what your plugin does.
|
||||||
|
|
||||||
|
## Loading and Unloading
|
||||||
|
|
||||||
|
- `on_load`: This method is called when the server loads your plugin. You should use this to register events, commands, and perform any initialization.
|
||||||
|
- `on_unload`: This method is called when the server unloads your plugin. Use this for cleanup if necessary.
|
||||||
30
docs/pt/plugin-dev/python/events.md
Normal file
30
docs/pt/plugin-dev/python/events.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Events
|
||||||
|
|
||||||
|
Events allow your plugin to respond to actions occurring on the server, such as players joining or messages being sent.
|
||||||
|
|
||||||
|
## Registering an Event
|
||||||
|
|
||||||
|
You can register an event handler in the `on_load` method of your plugin using `self.register_event`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Handlers
|
||||||
|
|
||||||
|
An event handler is a method that receives the server instance and the event data. It should return the (possibly modified) event data.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Types
|
||||||
|
|
||||||
|
The `event.EventType` enum contains all available events. Some common events include:
|
||||||
|
|
||||||
|
- `PLAYER_JOIN_EVENT`
|
||||||
|
- `PLAYER_QUIT_EVENT`
|
||||||
|
- `PLAYER_CHAT_EVENT`
|
||||||
@ -1,6 +1,18 @@
|
|||||||
# Python Plugin Development
|
# Quick Start
|
||||||
|
|
||||||
Pumpkin supports writing plugins in Python. Below is a basic example of a Python plugin.
|
This guide will help you get started with writing Pumpkin server plugins using Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
First, you need to install the `pumpkin-api-py` library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pumpkin-api-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating your first plugin
|
||||||
|
|
||||||
|
Create a file named `main.py` and add the following content:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from pumpkin_api import (
|
from pumpkin_api import (
|
||||||
@ -29,3 +41,13 @@ class MyPlugin(Plugin):
|
|||||||
|
|
||||||
register_plugin(MyPlugin)
|
register_plugin(MyPlugin)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
Build your plugin into a WebAssembly component using the provided build tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pumpkin-api-build main -o my_plugin.wasm
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||||
38
docs/tr_TR/plugin-dev/python/basic-logic.md
Normal file
38
docs/tr_TR/plugin-dev/python/basic-logic.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Basic Logic
|
||||||
|
|
||||||
|
This section covers the basic structure of a Pumpkin plugin in Python.
|
||||||
|
|
||||||
|
## Plugin Class
|
||||||
|
|
||||||
|
Every Python plugin must inherit from the `Plugin` class. This class provides the base structure and methods needed for the server to interact with your plugin.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import Plugin, PluginMetadata, context
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
# Define plugin metadata here
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is loaded
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_unload(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is unloaded
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The `metadata` method must return a `PluginMetadata` object, which contains information about your plugin.
|
||||||
|
|
||||||
|
- `name`: The name of your plugin.
|
||||||
|
- `version`: The version of your plugin.
|
||||||
|
- `authors`: A list of authors.
|
||||||
|
- `description`: A short description of what your plugin does.
|
||||||
|
|
||||||
|
## Loading and Unloading
|
||||||
|
|
||||||
|
- `on_load`: This method is called when the server loads your plugin. You should use this to register events, commands, and perform any initialization.
|
||||||
|
- `on_unload`: This method is called when the server unloads your plugin. Use this for cleanup if necessary.
|
||||||
30
docs/tr_TR/plugin-dev/python/events.md
Normal file
30
docs/tr_TR/plugin-dev/python/events.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Events
|
||||||
|
|
||||||
|
Events allow your plugin to respond to actions occurring on the server, such as players joining or messages being sent.
|
||||||
|
|
||||||
|
## Registering an Event
|
||||||
|
|
||||||
|
You can register an event handler in the `on_load` method of your plugin using `self.register_event`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Handlers
|
||||||
|
|
||||||
|
An event handler is a method that receives the server instance and the event data. It should return the (possibly modified) event data.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Types
|
||||||
|
|
||||||
|
The `event.EventType` enum contains all available events. Some common events include:
|
||||||
|
|
||||||
|
- `PLAYER_JOIN_EVENT`
|
||||||
|
- `PLAYER_QUIT_EVENT`
|
||||||
|
- `PLAYER_CHAT_EVENT`
|
||||||
53
docs/tr_TR/plugin-dev/python/quick-start.md
Normal file
53
docs/tr_TR/plugin-dev/python/quick-start.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Quick Start
|
||||||
|
|
||||||
|
This guide will help you get started with writing Pumpkin server plugins using Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
First, you need to install the `pumpkin-api-py` library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pumpkin-api-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating your first plugin
|
||||||
|
|
||||||
|
Create a file named `main.py` and add the following content:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import (
|
||||||
|
Plugin, PluginMetadata, register_plugin,
|
||||||
|
server, event, command, text, context
|
||||||
|
)
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
return PluginMetadata(
|
||||||
|
name="my-plugin",
|
||||||
|
version="0.1.0",
|
||||||
|
authors=["you"],
|
||||||
|
description="An example plugin."
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
print("Python plugin loaded!")
|
||||||
|
|
||||||
|
# Register an event handler
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
|
||||||
|
register_plugin(MyPlugin)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
Build your plugin into a WebAssembly component using the provided build tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pumpkin-api-build main -o my_plugin.wasm
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||||
@ -1,31 +0,0 @@
|
|||||||
# Python Plugin Development
|
|
||||||
|
|
||||||
Pumpkin supports writing plugins in Python. Below is a basic example of a Python plugin.
|
|
||||||
|
|
||||||
```python
|
|
||||||
from pumpkin_api import (
|
|
||||||
Plugin, PluginMetadata, register_plugin,
|
|
||||||
server, event, command, text, context
|
|
||||||
)
|
|
||||||
|
|
||||||
class MyPlugin(Plugin):
|
|
||||||
def metadata(self) -> PluginMetadata:
|
|
||||||
return PluginMetadata(
|
|
||||||
name="my-plugin",
|
|
||||||
version="0.1.0",
|
|
||||||
authors=["you"],
|
|
||||||
description="An example plugin."
|
|
||||||
)
|
|
||||||
|
|
||||||
def on_load(self, ctx: context.Context) -> None:
|
|
||||||
print("Python plugin loaded!")
|
|
||||||
|
|
||||||
# Register an event handler
|
|
||||||
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
|
||||||
|
|
||||||
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
|
||||||
print(f"Player {evt.player.get_name()} joined!")
|
|
||||||
return evt
|
|
||||||
|
|
||||||
register_plugin(MyPlugin)
|
|
||||||
```
|
|
||||||
@ -1,31 +0,0 @@
|
|||||||
# Python Plugin Development
|
|
||||||
|
|
||||||
Pumpkin supports writing plugins in Python. Below is a basic example of a Python plugin.
|
|
||||||
|
|
||||||
```python
|
|
||||||
from pumpkin_api import (
|
|
||||||
Plugin, PluginMetadata, register_plugin,
|
|
||||||
server, event, command, text, context
|
|
||||||
)
|
|
||||||
|
|
||||||
class MyPlugin(Plugin):
|
|
||||||
def metadata(self) -> PluginMetadata:
|
|
||||||
return PluginMetadata(
|
|
||||||
name="my-plugin",
|
|
||||||
version="0.1.0",
|
|
||||||
authors=["you"],
|
|
||||||
description="An example plugin."
|
|
||||||
)
|
|
||||||
|
|
||||||
def on_load(self, ctx: context.Context) -> None:
|
|
||||||
print("Python plugin loaded!")
|
|
||||||
|
|
||||||
# Register an event handler
|
|
||||||
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
|
||||||
|
|
||||||
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
|
||||||
print(f"Player {evt.player.get_name()} joined!")
|
|
||||||
return evt
|
|
||||||
|
|
||||||
register_plugin(MyPlugin)
|
|
||||||
```
|
|
||||||
38
docs/zh_cn/plugin-dev/python/basic-logic.md
Normal file
38
docs/zh_cn/plugin-dev/python/basic-logic.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# Basic Logic
|
||||||
|
|
||||||
|
This section covers the basic structure of a Pumpkin plugin in Python.
|
||||||
|
|
||||||
|
## Plugin Class
|
||||||
|
|
||||||
|
Every Python plugin must inherit from the `Plugin` class. This class provides the base structure and methods needed for the server to interact with your plugin.
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import Plugin, PluginMetadata, context
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
# Define plugin metadata here
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is loaded
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_unload(self, ctx: context.Context) -> None:
|
||||||
|
# Code to run when the plugin is unloaded
|
||||||
|
pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin Metadata
|
||||||
|
|
||||||
|
The `metadata` method must return a `PluginMetadata` object, which contains information about your plugin.
|
||||||
|
|
||||||
|
- `name`: The name of your plugin.
|
||||||
|
- `version`: The version of your plugin.
|
||||||
|
- `authors`: A list of authors.
|
||||||
|
- `description`: A short description of what your plugin does.
|
||||||
|
|
||||||
|
## Loading and Unloading
|
||||||
|
|
||||||
|
- `on_load`: This method is called when the server loads your plugin. You should use this to register events, commands, and perform any initialization.
|
||||||
|
- `on_unload`: This method is called when the server unloads your plugin. Use this for cleanup if necessary.
|
||||||
30
docs/zh_cn/plugin-dev/python/events.md
Normal file
30
docs/zh_cn/plugin-dev/python/events.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Events
|
||||||
|
|
||||||
|
Events allow your plugin to respond to actions occurring on the server, such as players joining or messages being sent.
|
||||||
|
|
||||||
|
## Registering an Event
|
||||||
|
|
||||||
|
You can register an event handler in the `on_load` method of your plugin using `self.register_event`.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Handlers
|
||||||
|
|
||||||
|
An event handler is a method that receives the server instance and the event data. It should return the (possibly modified) event data.
|
||||||
|
|
||||||
|
```python
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
```
|
||||||
|
|
||||||
|
## Event Types
|
||||||
|
|
||||||
|
The `event.EventType` enum contains all available events. Some common events include:
|
||||||
|
|
||||||
|
- `PLAYER_JOIN_EVENT`
|
||||||
|
- `PLAYER_QUIT_EVENT`
|
||||||
|
- `PLAYER_CHAT_EVENT`
|
||||||
53
docs/zh_cn/plugin-dev/python/quick-start.md
Normal file
53
docs/zh_cn/plugin-dev/python/quick-start.md
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Quick Start
|
||||||
|
|
||||||
|
This guide will help you get started with writing Pumpkin server plugins using Python.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
First, you need to install the `pumpkin-api-py` library:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install pumpkin-api-py
|
||||||
|
```
|
||||||
|
|
||||||
|
## Creating your first plugin
|
||||||
|
|
||||||
|
Create a file named `main.py` and add the following content:
|
||||||
|
|
||||||
|
```python
|
||||||
|
from pumpkin_api import (
|
||||||
|
Plugin, PluginMetadata, register_plugin,
|
||||||
|
server, event, command, text, context
|
||||||
|
)
|
||||||
|
|
||||||
|
class MyPlugin(Plugin):
|
||||||
|
def metadata(self) -> PluginMetadata:
|
||||||
|
return PluginMetadata(
|
||||||
|
name="my-plugin",
|
||||||
|
version="0.1.0",
|
||||||
|
authors=["you"],
|
||||||
|
description="An example plugin."
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_load(self, ctx: context.Context) -> None:
|
||||||
|
print("Python plugin loaded!")
|
||||||
|
|
||||||
|
# Register an event handler
|
||||||
|
self.register_event(ctx, event.EventType.PLAYER_JOIN_EVENT, self.on_player_join)
|
||||||
|
|
||||||
|
def on_player_join(self, srv: server.Server, evt: event.PlayerJoinEventData) -> event.PlayerJoinEventData:
|
||||||
|
print(f"Player {evt.player.get_name()} joined!")
|
||||||
|
return evt
|
||||||
|
|
||||||
|
register_plugin(MyPlugin)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building the plugin
|
||||||
|
|
||||||
|
Build your plugin into a WebAssembly component using the provided build tool:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pumpkin-api-build main -o my_plugin.wasm
|
||||||
|
```
|
||||||
|
|
||||||
|
This will generate a `my_plugin.wasm` file that you can place in the `plugins` folder of your Pumpkin server.
|
||||||
Loading…
Reference in New Issue
Block a user