namespace Minecraft.Server.FourKit.Command;
///
/// Represents a belonging to a plugin.
///
public class PluginCommand : Command
{
private CommandExecutor? _executor;
// should this remain internal?
///
/// Creates a new plugin command with the given name.
/// Use to obtain instances.
///
/// Name of this command.
internal PluginCommand(string name) : base(name)
{
}
///
public override bool execute(CommandSender sender, string commandLabel, string[] args)
{
if (_executor != null)
return _executor.onCommand(sender, this, commandLabel, args);
return false;
}
///
/// Gets the associated with this command.
///
/// The command executor, or null.
public CommandExecutor? getExecutor() => _executor;
///
/// Sets the to run when the command is dispatched.
///
/// New executor to set.
/// true if the executor was set.
public bool setExecutor(CommandExecutor executor)
{
_executor = executor;
return true;
}
}