namespace Minecraft.Server.FourKit.Command;
///
/// Represents a Command, which executes various tasks upon user input.
///
public abstract class Command
{
private string _name;
private string _description;
private string _usage;
private List _aliases;
///
/// Creates a new command with the given name and no aliases.
///
/// Name of this command.
protected Command(string name)
{
_name = name;
_description = string.Empty;
_usage = "/" + name;
_aliases = new List();
}
///
/// Creates a new command with the given name, description, and aliases.
///
/// Name of this command.
/// A brief description of this command.
/// A list of aliases for this command.
protected Command(string name, string description, List aliases)
{
_name = name;
_description = description ?? string.Empty;
_usage = "/" + name;
_aliases = aliases ?? new List();
}
///
/// Executes the command, returning its success.
///
/// Source of the command.
/// Alias of the command which was used.
/// Passed command arguments.
/// true if the command was successful, otherwise false.
public abstract bool execute(CommandSender sender, string commandLabel, string[] args);
///
/// Returns a list of active aliases of this command.
///
/// List of aliases.
public List getAliases() => new(_aliases);
///
/// Gets a brief description of this command.
///
/// Description of this command.
public string getDescription() => _description;
///
/// Returns the current label for this command.
///
/// Current label.
public string getLabel() => _name;
///
/// Returns the name of this command.
///
/// Name of this command.
public string getName() => _name;
///
/// Gets an example usage of this command.
///
/// Usage string.
public string getUsage() => _usage;
///
/// Sets the list of aliases to request on registration for this command.
///
/// Aliases to register.
/// This command.
public Command setAliases(List aliases)
{
_aliases = aliases ?? new List();
return this;
}
///
/// Sets a brief description of this command.
///
/// New command description.
/// This command.
public Command setDescription(string description)
{
_description = description ?? string.Empty;
return this;
}
///
/// Sets the example usage of this command.
///
/// New example usage.
/// This command.
public Command setUsage(string usage)
{
_usage = usage ?? string.Empty;
return this;
}
}