Creating Your First Plugin
This guide walks you through creating a basic Pumpkin plugin in Rust.Prerequisites
- Rust toolchain installed
- Basic understanding of Rust and async programming
- Pumpkin server source code
Project Setup
1. Create a New Library
Create a new Rust library project:2. Configure Cargo.toml
Set up yourCargo.toml to build a dynamic library:
Implementing the Plugin
Basic Plugin Structure
Here’s a minimal plugin implementation:Plugin Metadata
Define your plugin’s metadata:Plugin Entry Point
Export a function to create your plugin instance:Working with Context
TheContext object provides access to server functionality:
Building Your Plugin
Compile your plugin:target/release/:
- Linux:
libmy_plugin.so - Windows:
my_plugin.dll - macOS:
libmy_plugin.dylib
Installing the Plugin
- Copy the compiled library to the Pumpkin server’s
plugins/directory - Start or reload the server
- Check the logs to verify your plugin loaded successfully
Error Handling
Return errors from lifecycle hooks when initialization fails:Next Steps
- Plugin Lifecycle - Learn about lifecycle hooks in detail
- Event System - Register event handlers
- Explore the plugin API reference
