Esempio n. 1
0
        public static MProfile Parse(Minecraft mc, MProfileInfo info)
        {
            string json;

            if (info.IsWeb)
            {
                using (var wc = new WebClient())
                {
                    json = wc.DownloadString(info.Path);
                    return(ParseFromJson(mc, json, true));
                }
            }
            else
            {
                return(ParseFromFile(mc, info.Path));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get All MProfileInfo from mojang server
        /// </summary>
        public static MProfileInfo[] GetProfilesFromWeb()
        {
            JArray jarr;

            using (WebClient wc = new WebClient())
            {
                var jobj = JObject.Parse(wc.DownloadString(MojangServer.Profile));
                jarr = JArray.Parse(jobj["versions"].ToString());
            }

            var arr = new MProfileInfo[jarr.Count];

            for (int i = 0; i < jarr.Count; i++)
            {
                var obj = jarr[i].ToObject <MProfileInfo>();
                obj.IsWeb = true;
                arr[i]    = obj;
            }
            return(arr);
        }
Esempio n. 3
0
        /// <summary>
        /// Get All MProfileInfo from local
        /// </summary>
        public static MProfileInfo[] GetProfilesFromLocal(Minecraft mc)
        {
            var dirs = new DirectoryInfo(mc.Versions).GetDirectories();
            var arr  = new List <MProfileInfo>(dirs.Length);

            for (int i = 0; i < dirs.Length; i++)
            {
                var dir      = dirs[i];
                var filepath = System.IO.Path.Combine(dir.FullName, dir.Name + ".json");
                if (File.Exists(filepath))
                {
                    var info = new MProfileInfo();
                    info.IsWeb = false;
                    info.Name  = dir.Name;
                    info.Path  = filepath;
                    arr.Add(info);
                }
            }

            return(arr.ToArray());
        }