fCraft  0.638
Custom Minecraft Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events
fCraft.CommandManager Class Reference

Static class that allows registration and parsing of all text commands. More...

Static Public Member Functions

static CommandDescriptor[] GetCommands ()
 Gets a list of all commands (includding hidden ones).
 
static CommandDescriptor[] GetCommands (bool hidden)
 Gets a list of ONLY hidden or non-hidden commands, not both.
 
static CommandDescriptor[] GetCommands ([NotNull] Rank rank, bool includeHidden)
 Gets a list of commands available to a specified rank.
 
static CommandDescriptor[] GetCommands (CommandCategory category, bool includeHidden)
 Gets a list of commands in a specified category. Note that commands may belong to more than one category.
 
static void RegisterCustomCommand ([NotNull] CommandDescriptor descriptor)
 Registers a custom command with fCraft, to be made available for players to call. Raises CommandManager.CommandRegistering/CommandRegistered events. CommandRegistering event may silently cancel the registration.
 
static CommandDescriptor GetDescriptor ([NotNull] string commandName, bool alsoCheckAliases)
 Finds an instance of CommandDescriptor for a given command. Case-insensitive, but no autocompletion.
 
static bool ParseCommand ([NotNull] Player player,[NotNull] CommandReader cmd, bool fromConsole)
 Parses and calls a specified command.
 
static bool IsValidCommandName ([NotNull] string name)
 Checks whether a command name is acceptable. Constraints are similar to Player.IsValidName, except for length. Command names must bet between 1 and 16 characters long.
 

Static Public Attributes

static readonly string[] ReservedCommandNames = new[] { "ok", "nvm", "client" }
 Set of reserved command names (ok, nvm, and client).
 

Events

static EventHandler
< CommandRegistringEventArgs
CommandRegistering
 Occurs when a command is being registered (cancelable).
 
static EventHandler
< CommandRegisteredEventArgs
CommandRegistered
 Occurs when a command has been registered.
 
static EventHandler
< CommandCallingEventArgs
CommandCalling
 Occurs when a command is being called by a player or the console (cancelable).
 
static EventHandler
< CommandCalledEventArgs
CommandCalled
 Occurs when the command has been called by a player or the console.
 

Detailed Description

Static class that allows registration and parsing of all text commands.

Member Function Documentation

static CommandDescriptor [] fCraft.CommandManager.GetCommands ( )
static

Gets a list of all commands (includding hidden ones).

static CommandDescriptor [] fCraft.CommandManager.GetCommands ( bool  hidden)
static

Gets a list of ONLY hidden or non-hidden commands, not both.

static CommandDescriptor [] fCraft.CommandManager.GetCommands ( [NotNull] Rank  rank,
bool  includeHidden 
)
static

Gets a list of commands available to a specified rank.

static CommandDescriptor [] fCraft.CommandManager.GetCommands ( CommandCategory  category,
bool  includeHidden 
)
static

Gets a list of commands in a specified category. Note that commands may belong to more than one category.

static CommandDescriptor fCraft.CommandManager.GetDescriptor ( [NotNull] string  commandName,
bool  alsoCheckAliases 
)
static

Finds an instance of CommandDescriptor for a given command. Case-insensitive, but no autocompletion.

Parameters
commandNameCommand to find.
alsoCheckAliasesWhether to check command aliases.
Returns
Relevant CommandDesriptor object if found, null if not found.
Exceptions
ArgumentNullExceptioncommandName is null.
static bool fCraft.CommandManager.IsValidCommandName ( [NotNull] string  name)
static

Checks whether a command name is acceptable. Constraints are similar to Player.IsValidName, except for length. Command names must bet between 1 and 16 characters long.

Parameters
nameCommand name to check.
Returns
True if the given name is valid; otherwise false.
Exceptions
ArgumentNullExceptionname is null.
static bool fCraft.CommandManager.ParseCommand ( [NotNull] Player  player,
[NotNull] CommandReader  cmd,
bool  fromConsole 
)
static

Parses and calls a specified command.

Parameters
playerPlayer who issued the command.
cmdCommand to be parsed and executed.
fromConsoleWhether this command is being called from a non-player (e.g. Console).
Returns
True if the command was called, false if something prevented it from being called.
Exceptions
ArgumentNullExceptionplayer or cmd is null.
static void fCraft.CommandManager.RegisterCustomCommand ( [NotNull] CommandDescriptor  descriptor)
static

Registers a custom command with fCraft, to be made available for players to call. Raises CommandManager.CommandRegistering/CommandRegistered events. CommandRegistering event may silently cancel the registration.

Parameters
descriptorCommand descriptor to register.
Exceptions
ArgumentNullExceptiondescriptor is null.
CommandRegistrationExceptionCommand descriptor could not be registered. Check exception message for details. Possible reasons include: No category/name/handler was set; a command with the same name has already been registed; command name is reserved; or one of the aliases of given command matches the name of another registered command.

Member Data Documentation

readonly string [] fCraft.CommandManager.ReservedCommandNames = new[] { "ok", "nvm", "client" }
static

Set of reserved command names (ok, nvm, and client).

Event Documentation

EventHandler<CommandCalledEventArgs> fCraft.CommandManager.CommandCalled
static

Occurs when the command has been called by a player or the console.

EventHandler<CommandCallingEventArgs> fCraft.CommandManager.CommandCalling
static

Occurs when a command is being called by a player or the console (cancelable).

EventHandler<CommandRegisteredEventArgs> fCraft.CommandManager.CommandRegistered
static

Occurs when a command has been registered.

EventHandler<CommandRegistringEventArgs> fCraft.CommandManager.CommandRegistering
static

Occurs when a command is being registered (cancelable).


The documentation for this class was generated from the following file: