ServerPack: ServerUsageLines, a server's own /rserver usage lines

An optional hook, collected once in the constructor. ServerPackCommands.Usage
appends a server's lines (trimmed, blanks dropped) after the shared two, and
"/rserver help" and an unknown word print them all. A server without the hook
prints exactly the two lines it always has (pinned on Coldeve).
ServerProjectsTests.PluginsDir is internal so other tests can share it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Daniel Wallace 2026-11-07 15:46:37 -08:00
commit 8ceba81070
4 changed files with 49 additions and 9 deletions

View file

@ -32,6 +32,7 @@
// SetProfileValue(key, n) a live number in its "RynthServer.Profile" ("values"), for other
// plugins that apply a server rule without knowing the server.
// ServerCommandVerbs(list) its own "/rserver <verb>" words, handled in ServerChatCommand.
// ServerUsageLines(add) the usage lines for those words, after the shared two (help, unknown word).
// RunOnTick(action) work for the next tick (a page's button, on the render thread).
// ServerCardActions() the server's own buttons at the top of its card, under RynthCore's verdict
// (render thread: ImGui calls only; queue work with RunOnTick).
@ -87,6 +88,8 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
private readonly ConcurrentQueue<Action> _tickActions = new();
// The server's own "/rserver" verbs (ServerCommandVerbs).
private readonly HashSet<string> _serverVerbs = new(StringComparer.OrdinalIgnoreCase);
// The server's own "/rserver" usage lines (ServerUsageLines), after the shared two.
private readonly List<string> _usageLines = new();
private volatile bool _loginComplete;
private volatile string? _world;
private bool _wasActive;
@ -104,6 +107,7 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
var verbs = new List<string>();
ServerCommandVerbs(verbs);
foreach (string v in verbs) if (!string.IsNullOrWhiteSpace(v)) _serverVerbs.Add(v.Trim());
ServerUsageLines(_usageLines.Add);
_ui = new ServerPackUi(_model, RynthPluginInfo.Name + " " + Marshal.PtrToStringAnsi(VersionPointer), () => _world, _pages, DrawCardActions);
}
@ -135,6 +139,11 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
/// instead of being read as another server's id. Called once, from the constructor.
/// </summary>
partial void ServerCommandVerbs(List<string> verbs);
/// <summary>
/// Usage lines for the server's own verbs, printed after the shared two by "/rserver help" and an
/// unknown word. Called once, from the constructor (no Host yet).
/// </summary>
partial void ServerUsageLines(Action<string> add);
/// <summary>Extra lines for "/rserver info".</summary>
partial void ServerInfoLines(Action<string> line);
/// <summary>The server's own pages (ServerPackPages.cs). Called once, from the constructor (no Host yet).</summary>
@ -475,9 +484,10 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
bool handled = false;
ServerChatCommand(parts, ref handled);
if (handled) return;
if (verb == ServerVerb.Unknown) Reply.Fail(ServerPackCommands.Unknown(parts[1]) + " " + ServerPackCommands.Usage(Info.Name)[0]);
else ChatLine(ServerPackCommands.Usage(Info.Name)[0]);
ChatLine(ServerPackCommands.Usage(Info.Name)[1]);
string[] usage = ServerPackCommands.Usage(Info.Name, _usageLines);
if (verb == ServerVerb.Unknown) Reply.Fail(ServerPackCommands.Unknown(parts[1]) + " " + usage[0]);
else ChatLine(usage[0]);
for (int i = 1; i < usage.Length; i++) ChatLine(usage[i]);
}
private void PrintInfo()