Beispiel #1
0
        /// <summary>
        /// Get All MProfileInfo from mojang server
        /// </summary>
        public static MProfileMetadata[] GetProfileMetadatasFromWeb()
        {
            JArray jarr;

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

            var arr = new MProfileMetadata[jarr.Count];

            for (int i = 0; i < jarr.Count; i++)
            {
                var obj = jarr[i].ToObject <MProfileMetadata>();
                obj.IsWeb = true;
                obj.MType = MProfileTypeConverter.FromString(obj.Type);
                arr[i]    = obj;
            }
            return(arr);
        }
Beispiel #2
0
        /// <summary>
        /// Get All MProfileInfo from local
        /// </summary>
        public static MProfileMetadata[] GetProfileMetadatasFromLocal(Minecraft mc)
        {
            var dirs = new DirectoryInfo(mc.Versions).GetDirectories();
            var arr  = new List <MProfileMetadata>(dirs.Length);

            foreach (var dir in dirs)
            {
                var filepath = Path.Combine(dir.FullName, dir.Name + ".json");
                if (!File.Exists(filepath))
                {
                    continue;
                }
                var info = new MProfileMetadata();
                info.IsWeb = false;
                info.Name  = dir.Name;
                info.Path  = filepath;
                info.Type  = "local";
                info.MType = MProfileType.Custom;
                arr.Add(info);
            }

            return(arr.ToArray());
        }