public static bool ParseCommand( [NotNull] Player player, [NotNull] Command cmd, bool fromConsole )
{
if ( player == null )
throw new ArgumentNullException( "player" );
if ( cmd == null )
throw new ArgumentNullException( "cmd" );
CommandDescriptor descriptor = GetDescriptor( cmd.Name, true );
if ( descriptor == null ) {
player.Message( "Unknown command \"{0}\". See &H/Commands", cmd.Name );
return false;
}
if ( !descriptor.IsConsoleSafe && fromConsole ) {
player.Message( "You cannot use this command from console." );
} else {
if ( descriptor.Permissions != null ) {
if ( !descriptor.CanBeCalledBy( player.Info.Rank ) ) {
player.MessageNoAccess( descriptor );
} else if ( !descriptor.Call( player, cmd, true ) ) {
player.Message( "Command was cancelled." );
} else {
return true;
}
} else {
if ( descriptor.Call( player, cmd, true ) ) {
return true;
} else {
player.Message( "Command was cancelled." );
}
}
}
return false;
}