protected override void Init() { Settings = LocalRecordsSettings.ReadFromFile(PluginSettingsFilePath); try { AdapterProvider = AdapterProviderFactory.GetAdapterProvider(Settings); ChallengeAdapter = AdapterProvider.GetChallengeAdapter(); PlayerAdapter = AdapterProvider.GetPlayerAdapter(); PositionAdapter = AdapterProvider.GetPositionAdapter(); RecordAdapter = AdapterProvider.GetRecordAdapter(); RatingAdapter = AdapterProvider.GetRatingAdapter(); SessionAdapter = AdapterProvider.GetSessionAdapter(); RankingAdapter = AdapterProvider.GetRankingAdapter(); } catch (Exception ex) { Logger.Error("Error initializing AdapterProvider for local records.", ex); Logger.ErrorToUI(string.Format("An error occured. {0} not started!", Name)); return; } List <ChallengeListSingleInfo> challenges = GetChallengeList(); if (challenges == null) { return; } try { Logger.InfoToUI("Starting to delete data of missing tracks"); int amountOfDeletedTracks = ChallengeAdapter.DeleteTracksNotInProvidedList(challenges.ConvertAll(c => c.UId)); Logger.InfoToUI(string.Format("Data of {0} Track(s) has been deleted.", amountOfDeletedTracks)); } catch (Exception ex) { Logger.ErrorToUI("Couldn't delete data of missing tracks.", ex); } foreach (PlayerSettings playerSettings in Context.PlayerSettings.GetAllAsList()) { if (!playerSettings.NickName.IsNullOrTimmedEmpty()) { PlayerAdapter.CreateOrUpdate(new Player(playerSettings.Login, playerSettings.NickName)); } } ChallengeInfo currentChallengeInfo = GetCurrentChallengeInfoCached(); if (currentChallengeInfo == null) { Logger.ErrorToUI(string.Format("An error occured. {0} not started!", Name)); return; } EnsureChallengeExistsInStorage(currentChallengeInfo); DetermineLocalRecords(); InitializePlugins(); OnLocalRecordsDetermined(new List <RankEntry>(LocalRecords)); Context.RPCClient.Callbacks.BeginRace += Callbacks_BeginRace; Context.RPCClient.Callbacks.EndRace += Callbacks_EndRace; Context.RPCClient.Callbacks.PlayerConnect += Callbacks_PlayerConnect; Context.RPCClient.Callbacks.PlayerDisconnect += Callbacks_PlayerDisconnect; Context.RPCClient.Callbacks.PlayerFinish += Callbacks_PlayerFinish; Context.RPCClient.Callbacks.PlayerChat += Callbacks_PlayerChat; }