VampireCommandFramework
Command framework for developers to easily create universal commands for their plugins.
截圖 共 1 張
模組介紹 作者原文
VampireCommandFramework
A comprehensive framework for V Rising mod developers to easily build commands with advanced features like command overloading, history, smart matching, and plugin-specific execution.
Usage
For Server Operators
This plugin should be installed into the BepInEx/plugins folder and be kept up to date. It is required by other plugins for commands.
For Plugin Developers
How to use
- Add a reference to the plugin
dotnet add package VRising.VampireCommandFramework
- Add the plugin as a dependency by setting this attribute on your plugin class
[BepInDependency("gg.deca.VampireCommandFramework")]
- Register your plugin when you're done loading:
CommandRegistry.RegisterAll()
- Write commands
[Command("foo")]
public void Foo(ICommandContext ctx, int count, string orValues = "with defaults", float someFloat = 3f)
=> ctx.Reply($"You'd do stuff here with your parsed {count} and stuff");
This command would execute for:
-.foo 5
-.foo 5 works
-.foo 5 "or really fancy" 3.145
But if you typed.foo 5.123 you'd see a generated usage message like:.foo (count) [orValues="with defaults"] [someFloat=3]
This simple example provides
- Automatic help listings - your command appears in.help
- Parameter parsing - count, orValues, and someFloat are automatically converted
- Usage text generation - help shows (count) [orValues="with defaults"] [someFloat=3]
- Default parameter handling - optional parameters work seamlessly
- Type conversion - strings become integers, floats, etc.
More Examples
The framework handles these additional command patterns:
Command with parameters:
[Command("give")]
public void GiveItem(ICommandContext ctx, string item, int count = 1)
=> ctx.Reply($"Gave {count} {item}");
- Executes with:.give sword,.give sword 5
Command groups:
[CommandGroup("admin")]
public class AdminCommands
{
[Command("ban")]
public void Ban(ICommandContext ctx, string player)
=> ctx.Reply($"Banned {player}");
}
- Executes with:.admin ban PlayerName
Remainder Parameters
For commands that take free-form text (a message, a reason, a timezone ID), mark the final string parameter with [Remainder] to capture everything the user typed after the preceding arguments, with spacing and quotes preserved.
[Command("say")]
public void Say(ICommandContext ctx, string channel, [Remainder] string message)
=> ctx.Reply($"[{channel}] {message}");
-.say global hello everyone → channel = "global", message = "hello everyone"
-.say global "hello, friends!" → message = "\"hello, friends!\"" (quotes kept as typed)
Rules:
- Must be the last parameter. Violations are rejected at registration time.
- Must be of type string.
- Captures the rest of the raw input verbatim, including quotes, whitespace, and special characters.
- Can be optional with a default value: [Remainder] string reason = null.
- Parameters before the remainder are parsed normally: type conversion, defaults, and custom converters all still apply.
- Composes with overloading: the framework picks a remainder variant when enough preceding arguments are present.
Auto-generated.help output renders a remainder parameter as `, distinct from (name) for required and [name=default] for optional, so users get a visual cue for free, unless you supply a manual usage: string on [Command]`.
Command Overloading
You can now create multiple commands with the same name but different parameter types:
[Command("teleport")]
public void TeleportToPlayer(ICommandContext ctx, string playerName)
=> ctx.Reply($"Teleporting to {playerName}");
[Command("teleport")]
public void TeleportToCoords(ICommandContext ctx, float x, float y)
=> ctx.Reply($"Teleporting to {x}, {y}");
When there's ambiguity, players will be presented with options and can select using.1,.2, etc.
Middleware
All commands execute through a middleware pipeline. You can add your own middleware by implementing ICommandMiddleware and adding it to the CommandRegistry.Middlewares list.
Middleware is perfect for imple
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: