diff --git a/CommandHook/CommandData.cs b/CommandHook/CommandData.cs
index b7b905c..4c44adc 100644
--- a/CommandHook/CommandData.cs
+++ b/CommandHook/CommandData.cs
@@ -2,23 +2,54 @@ using Vintagestory.API.Server;
namespace CommandHook;
+///
+/// The data passed to Before/After listeners for a single command invocation.
+/// Passed by ref through the hot path, no allocation per command.
+///
public struct CommandData
{
+ ///
+ /// The player who ran the command, or null if it came from the server console.
+ ///
public readonly IServerPlayer? Sender;
+
+ ///
+ /// The full command text as typed, including the leading slash.
+ ///
public readonly string FullCommand;
+
+ ///
+ /// The command name only, without the leading slash (matches what listeners
+ /// register in ).
+ ///
public readonly string CommandName;
private byte flags;
private const byte FlagIsPlayerCommand = 1 << 0;
private const byte FlagCancel = 1 << 1;
+ ///
+ /// True if a player ran this command, false if it came from the server console.
+ /// Equivalent to Sender != null.
+ ///
public bool IsPlayerCommand => (flags & FlagIsPlayerCommand) != 0;
+
+ ///
+ /// Set this to true in a Before listener to stop the command from executing.
+ /// Stops any remaining Before listeners from running too, and skips After entirely.
+ ///
public bool Cancel
{
get => (flags & FlagCancel) != 0;
set => flags = value ? (byte)(flags | FlagCancel) : (byte)(flags & ~FlagCancel);
}
+ ///
+ /// Creates the command data for a single invocation.
+ ///
+ /// The player who ran the command, or null for console.
+ /// The command name without the leading slash.
+ /// The full command text as typed, including the leading slash.
public CommandData(IServerPlayer? sender, string commandName, string fullCommand)
{
Sender = sender;