docs(CommandData): add XML doc comments to public surface
This commit is contained in:
@@ -2,23 +2,54 @@ using Vintagestory.API.Server;
|
|||||||
|
|
||||||
namespace CommandHook;
|
namespace CommandHook;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The data passed to Before/After listeners for a single command invocation.
|
||||||
|
/// Passed by ref through the hot path, no allocation per command.
|
||||||
|
/// </summary>
|
||||||
public struct CommandData
|
public struct CommandData
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The player who ran the command, or null if it came from the server console.
|
||||||
|
/// </summary>
|
||||||
public readonly IServerPlayer? Sender;
|
public readonly IServerPlayer? Sender;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The full command text as typed, including the leading slash.
|
||||||
|
/// </summary>
|
||||||
public readonly string FullCommand;
|
public readonly string FullCommand;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The command name only, without the leading slash (matches what listeners
|
||||||
|
/// register in <see cref="ICommandHookListener.Commands"/>).
|
||||||
|
/// </summary>
|
||||||
public readonly string CommandName;
|
public readonly string CommandName;
|
||||||
private byte flags;
|
private byte flags;
|
||||||
|
|
||||||
private const byte FlagIsPlayerCommand = 1 << 0;
|
private const byte FlagIsPlayerCommand = 1 << 0;
|
||||||
private const byte FlagCancel = 1 << 1;
|
private const byte FlagCancel = 1 << 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if a player ran this command, false if it came from the server console.
|
||||||
|
/// Equivalent to <c>Sender != null</c>.
|
||||||
|
/// </summary>
|
||||||
public bool IsPlayerCommand => (flags & FlagIsPlayerCommand) != 0;
|
public bool IsPlayerCommand => (flags & FlagIsPlayerCommand) != 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
public bool Cancel
|
public bool Cancel
|
||||||
{
|
{
|
||||||
get => (flags & FlagCancel) != 0;
|
get => (flags & FlagCancel) != 0;
|
||||||
set => flags = value ? (byte)(flags | FlagCancel) : (byte)(flags & ~FlagCancel);
|
set => flags = value ? (byte)(flags | FlagCancel) : (byte)(flags & ~FlagCancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the command data for a single invocation.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The player who ran the command, or null for console.</param>
|
||||||
|
/// <param name="commandName">The command name without the leading slash.</param>
|
||||||
|
/// <param name="fullCommand">The full command text as typed, including the leading slash.</param>
|
||||||
public CommandData(IServerPlayer? sender, string commandName, string fullCommand)
|
public CommandData(IServerPlayer? sender, string commandName, string fullCommand)
|
||||||
{
|
{
|
||||||
Sender = sender;
|
Sender = sender;
|
||||||
|
|||||||
Reference in New Issue
Block a user