插件安装教学
本文基于 E:/code/qexed_doc_pr 的最新实现(f57af391ad79823aac42b78399cefdc381ed31fc),演示如何构建并安装 WASM 插件。
前置条件
- 已完成 安装
- 服务端目录可正常启动
qexed.exe - 需要从源码构建插件时,已安装 Rust toolchain
目录结构
Qexed 会在启动时扫描 plugins/*.wasm:
server/
qexed.exe
config/
plugins/
hello_world.wasm
player_audit.wasm
从示例源码构建插件
rustup target add wasm32-unknown-unknown
cargo build --manifest-path "plugins/examples/Cargo.toml" --target wasm32-unknown-unknown --release
构建产物在 plugins/examples/target/wasm32-unknown-unknown/release/。
安装步骤
- 在服务端根目录确保存在
plugins目录。 - 复制
.wasm文件到plugins/(不是子目录)。 - 重启 Qexed,检查日志是否加载成功。
示例:
Copy-Item "plugins/examples/target/wasm32-unknown-unknown/release/hello_world.wasm" "plugins/"
Copy-Item "plugins/examples/target/wasm32-unknown-unknown/release/player_audit.wasm" "plugins/"
快速验证
- 启动日志应出现插件加载信息。
chunk_trace会输出大量区块日志,仅建议用于 ABI 调试。slime_jump与double_jump可用于验证事件与动作回调。
常见问题
插件未被发现
- 确认文件后缀是
.wasm。 - 确认文件位于
plugins/根目录,而不是plugins/<name>/。
启动时报 ABI 或符号错误
- 确认目标是
wasm32-unknown-unknown。 - 确认插件导出
memory与qexed_plugin_alloc(len: i32) -> i32。