Beispiel #1
0
        public static void UpdateScoreSaberData(string _ScoreSaberID)
        {
            string _url         = "https://new.scoresaber.com/api/player/" + _ScoreSaberID + "/basic";
            string _json        = new WebClient().DownloadString(_url);
            var    _newProfile  = JsonConvert.DeserializeObject <Classes.Profile>(_json);
            var    _newProfile2 = _newProfile.playerInfo;

            for (int i = 0; i < ScoreTrackerController.profileList.Count(); i++)
            {
                bool _save = false;
                if (ScoreTrackerController.profileList[i].playerId == _newProfile2.playerId)
                {
                    foreach (var item in ScoreTrackerController.trackedList)
                    {
                        if (item.playerID == _newProfile2.playerId)
                        {
                            item.pp          = _newProfile2.pp;
                            item.rank        = _newProfile2.rank;
                            item.countryRank = _newProfile2.countryRank;
                            if (ScoreTrackerController.profileList[i].rank != _newProfile2.rank)
                            {
                                _save = true;
                            }
                            else if (ScoreTrackerController.profileList[i].countryRank != _newProfile2.countryRank)
                            {
                                _save = true;
                            }
                            else if (ScoreTrackerController.profileList[i].pp != _newProfile2.pp)
                            {
                                _save = true;
                            }
                        }
                    }
                    ScoreTrackerController.profileList[i].avatar      = _newProfile2.avatar;
                    ScoreTrackerController.profileList[i].badges      = _newProfile2.badges;
                    ScoreTrackerController.profileList[i].banned      = _newProfile2.banned;
                    ScoreTrackerController.profileList[i].country     = _newProfile2.country;
                    ScoreTrackerController.profileList[i].countryRank = _newProfile2.countryRank;
                    ScoreTrackerController.profileList[i].history     = _newProfile2.history;
                    ScoreTrackerController.profileList[i].inactive    = _newProfile2.inactive;
                    ScoreTrackerController.profileList[i].permissions = _newProfile2.permissions;
                    ScoreTrackerController.profileList[i].playerName  = _newProfile2.playerName;
                    ScoreTrackerController.profileList[i].pp          = _newProfile2.pp;
                    ScoreTrackerController.profileList[i].rank        = _newProfile2.rank;
                    ScoreTrackerController.profileList[i].role        = _newProfile2.role;


                    if (_save)
                    {
                        ToDB.SaveTracked();
                    }

                    break;
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Called when the script is being destroyed.
 /// </summary>
 private void OnDestroy()
 {
     BSEvents.menuSceneActive -= UpdateScoreTracker;
     ToDB.SaveProfiles();
     ToDB.SaveTracked();
     Plugin.Log?.Debug($"{name}: OnDestroy()");
     if (Instance == this)
     {
         Instance = null; // This MonoBehaviour is being destroyed, so set the static instance property to null.
     }
 }
Beispiel #3
0
        public static void GetScoreSaberData(string _ScoreSaberID)
        {
            string _url         = "https://new.scoresaber.com/api/player/" + _ScoreSaberID + "/basic";
            string _json        = new WebClient().DownloadString(_url);
            var    _newProfile  = JsonConvert.DeserializeObject <Classes.Profile>(_json);
            var    _newProfile2 = _newProfile.playerInfo;

            _newProfile2.compare = true;
            _newProfile2.tracked = true;
            ScoreTrackerController.profileList.Add(_newProfile2);
            ScoreTrackerController.trackedList.Add(new Classes.Tracked(_newProfile2.timestampu,
                                                                       _newProfile2.playerId, _newProfile2.playerName, _newProfile2.pp,
                                                                       _newProfile2.rank, _newProfile2.countryRank,
                                                                       _newProfile2.country, _newProfile2.timestamp));
            ToDB.SaveProfiles();
            ToDB.SaveTracked();
        }