Skip to content

Plugin Engine Architecture

Pumpkin features a modular, multi-runtime plugin engine designed for performance, safety, and cross-language interoperability.

Unlike traditional Minecraft servers that rely on a single JVM class loader, Pumpkin isolates plugin execution through dedicated loaders supporting both native high-performance Rust binaries and sandboxed WebAssembly components compiled from Rust, Python, C#, C, Go, or Kotlin.


Architectural Overview

Architectural Breakdown

SubsystemPrimary CrateResponsibility
Plugin Managercrates/pumpkin/src/pluginLifecycle orchestration (load, enable, disable), event dispatching, and loader registration
Native Loadercrates/pumpkin/src/plugin/loader/nativeDirect dynamic library loading (.so, .dll, .dylib) for zero-overhead Rust extensions
WASM Loadercrates/pumpkin/src/plugin/loader/wasmWasmtime execution engine for sandboxed components compiled from Rust, Python, Go, C#, C, and Kotlin
Interface Specificationscrates/pumpkin-plugin-witWebAssembly Interface Types (WIT) defining typed functions, types, and host imports
Security & Verificationcrates/pumpkin/src/plugin/loader/wasm/signCryptographic signature verification via W3C wasmsign2 / Ed25519 public keys

The Dual Execution Model

FeatureNative PluginsWebAssembly (Wasmtime) Plugins
File Extension.so (Linux), .dll (Windows), .dylib (macOS).wasm (Component Model)
LanguagesRust (compiled dynamically)Rust, Python, C#, C, Go, Kotlin
PerformanceNative CPU execution (zero overhead)JIT-compiled with near-native speed
SandboxingNone (runs in host address space)Memory-isolated sandboxed execution
Security & SigningOS-level permissionsCryptographic W3C Wasm-Sign verification
Hot UnloadingLimited (OS shared library constraints)Fully supported memory reclamation

Event Lifecycle & Dispatching

Plugins interact with Pumpkin primarily through events:

  1. Event Dispatch:
    • server.plugin_manager.fire_blocking(&server, &mut event): Dispatches events synchronously on the executing thread (e.g., cancelling player block placement or modifying packet payloads).
    • Asynchronous events run on non-blocking Tokio tasks.
  2. Cancellable Events:
    • Handlers can set event.cancelled = true to abort the default game logic (such as cancelling player movement, interactions, or packet processing).

Plugin Engine Documentation

Explore the internal mechanics of Pumpkin's plugin system:

  • Adding a Plugin Loader: Step-by-step guide on implementing the PluginLoader trait for new scripting languages and runtimes.
  • WASM Signing & Verification: Detailed specification of Ed25519 cryptographic signing, W3C wasmsign2 custom sections, and marketplace license verification.

NOTE

Looking to develop third-party plugins rather than working on Pumpkin's internal plugin engine? Check out the Plugin Development Guide.

Lançado sob a licença MIT.