Пример #1
0
        public override string GenerateClasspath()
        {
            RuleReader rr        = new RuleReader();
            string     classpath = "";

            foreach (JObject i in vdata["libraries"])
            {
                rr.Execute(new Func <JArray>(() =>
                {
                    if (i.ContainsKey("rules"))
                    {
                        return((JArray)i["rules"]);
                    }
                    return(null);
                })(),
                           () =>
                {
                    if (i.ContainsKey("natives"))
                    {
                        classpath += Path.GetFullPath("libraries/" + (string)i["downloads"]["classifiers"]["natives-windows"]["path"]) + ";";
                    }
                    else
                    {
                        classpath += Path.GetFullPath("libraries/" + (string)i["downloads"]["artifact"]["path"]) + ";";
                    }
                });
            }
            classpath += $"versions/{VID}/{VID}.jar";
            return(classpath);
        }
Пример #2
0
        protected override void CheckLibraries(string path)
        {
            string             o         = SetCurrentDirectory(path);
            RuleReader         rr        = new RuleReader();
            HashSet <Download> downloads = new HashSet <Download>();

            foreach (JObject i in vdata["libraries"])
            {
                rr.Execute(new Func <JArray>(() =>
                {
                    if (i.ContainsKey("rules"))
                    {
                        return((JArray)i["rules"]);
                    }
                    return(null);
                })(),
                           () =>
                {
                    if (i.ContainsKey("natives"))
                    {
                        downloads.Add(new Download(
                                          (string)i["downloads"]["classifiers"]["natives-windows"]["url"],
                                          "libraries/" + (string)i["downloads"]["classifiers"]["natives-windows"]["path"],
                                          (string)i["downloads"]["classifiers"]["natives-windows"]["sha1"]
                                          ));
                    }
                    else
                    {
                        downloads.Add(new Download(
                                          (string)i["downloads"]["artifact"]["url"],
                                          "libraries/" + (string)i["downloads"]["artifact"]["path"],
                                          (string)i["downloads"]["artifact"]["sha1"]
                                          ));
                    }
                });
            }
            Util.CheckFiles(downloads);
            Directory.SetCurrentDirectory(o);
        }
Пример #3
0
        public override List <string> GenerateArgs(ILoginClient login, Profile profile)
        {
            List <string> arguments = new List <string>();
            RuleReader    rr        = new RuleReader
            {
                Login = login
            };
            Hashtable arghash = GenParamHash(login, profile);
            // Apply default parameters.
            JArray input = (JArray)vdata["arguments"]["game"];

            foreach (JToken i in input)
            {
                if (i.HasValues)
                {
                    rr.Execute((JArray)(i["rules"]), () =>
                    {
                        if (i["value"].HasValues)
                        {
                            foreach (string v in i["value"])
                            {
                                arguments.Add(new Formatter().Format(v, arghash));
                            }
                        }
                        else
                        {
                            arguments.Add(new Formatter().Format((string)i["value"], arghash));
                        }
                    });
                }
                else
                {
                    // Boilerplate code found here...
                    arguments.Add(new Formatter().Format((string)i, arghash));
                }
            }
            return(arguments);
        }
 public RuleController(RuleReader ruleReader)
 {
     this.ruleReader = ruleReader;
 }