public AppConfig(string folder, YamlMappingNode yaml)
 {
     GitInstallationPath = Util.FilePath(folder, yaml["git install"]);
     GitIgnoreContents   = yaml.Go("gitignore").String();
     Java    = new JavaConfig(folder, this, yaml["java"] as YamlMappingNode);
     Bedrock = new BedrockConfig(folder, this, yaml["bedrock"] as YamlMappingNode);
 }
    private void RunDataGenerators(JavaConfig config, string folder)
    {
        string reports_path = Path.Combine(config.ServerJarFolder, "generated");

        if (Directory.Exists(reports_path))
        {
            Directory.Delete(reports_path, true);
        }

        DownloadServerJar(config);
        if (Server.JarPath is not null)
        {
            Profiler.Start("Fetching data reports");
            string args1  = $"-cp \"{Server.JarPath}\" net.minecraft.data.Main --reports";
            string args2  = $"-DbundlerMainClass=net.minecraft.data.Main -jar \"{Server.JarPath}\" --reports";
            var    result = CommandRunner.RunJavaCombos(
                config.ServerJarFolder,
                config.JavaInstallationPaths,
                new[] { args1, args2 }
                );
            if (result.ExitCode != 0)
            {
                throw new ApplicationException("Failed to get data reports");
            }
            Directory.CreateDirectory(folder);
            FileSystem.CopyDirectory(Path.Combine(reports_path, "reports"), folder);
            if (Directory.Exists(reports_path))
            {
                Directory.Delete(reports_path, true);
            }
            Profiler.Stop();
        }
    }
    private void FetchAssets(JavaConfig config, string json_path, string folder)
    {
        Profiler.Start("Fetching assets");
        var assets_file = Util.DownloadString(AssetsURL);

        File.WriteAllText(json_path, assets_file);
        var json = JsonObject.Parse(assets_file);

        foreach ((string path, JsonNode data) in (JsonObject)json["objects"])
        {
            var hash        = (string)data["hash"];
            var cached      = Path.Combine(config.AssetsFolder, "objects", hash[0..2], hash);
 private void ExtractJar(JavaConfig config, string folder)
 {
     Profiler.Start($"Extracting jar");
     using ZipArchive zip = ZipFile.OpenRead(Client.JarPath);
     foreach (var entry in zip.Entries)
     {
         if (entry.FullName.EndsWith("/") || config.ExcludeJarEntry(entry.FullName))
         {
             continue;
         }
         Directory.CreateDirectory(Path.Combine(folder, Path.GetDirectoryName(entry.FullName)));
         var destination = Path.Combine(folder, entry.FullName);
         entry.ExtractToFile(destination);
     }
     Profiler.Stop();
 }
Esempio n. 5
0
        private void Btn2_Click(object sender, EventArgs e)
        {
            string json = inputBox.Text;
            UserConfig <BaseConfig> config = ConfigUtil.ReadConfig(json);
            HookType type    = (HookType)Enum.Parse(typeof(HookType), config.Type.ToUpper());
            int      counter = 0;
            string   res     = "";

            foreach (BaseConfig cr in config.ConfigList)
            {
                switch (type)
                {
                case HookType.JAVA:
                {
                    JavaConfig result = (JavaConfig)cr;
                    foreach (Dictionary <string, JavaParaItem> chk in result.ParamConfig)
                    {
                        List <Object> checkedItems = chk.Values.ToList <Object>();
                        string        script       = CodeUtil.GenJavaCode(result.ClassName, result.FunctionName, result.Param, checkedItems, result.ParamCount, counter++);
                        res += "\r\n" + script;
                    }
                }
                break;

                case HookType.NATIVE:
                {
                    NativeConfig result = (NativeConfig)cr;
                    foreach (Dictionary <string, NativeParaItem> chk in result.ParamConfig)
                    {
                        List <Object> checkedItems = chk.Values.ToList <Object>();
                        string        script       = CodeUtil.GenNativeCode(result.ModelName, result.Address, checkedItems, counter++);
                        res += "\r\n" + script;
                    }
                    //outputBox.Text = res;
                    //outputBox.Refresh();
                }
                break;

                default:
                    break;
                }
            }
            outputBox.Text = res;
            outputBox.Refresh();
        }
Esempio n. 6
0
        private List <BaseConfig> ConstractResults(DataGridView grid, HookType type)
        {
            grid.EndEdit();
            List <BaseConfig> results = new List <BaseConfig>();

            foreach (DataGridViewRow row in grid.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                string className    = Convert.ToString(((DataGridViewTextBoxCell)row.Cells[0]).Value);
                string functionName = Convert.ToString(((DataGridViewTextBoxCell)row.Cells[1]).Value);
                string param        = Convert.ToString(((DataGridViewTextBoxCell)row.Cells[2]).Value);
                int    paramCount   = Convert.ToInt32(((DataGridViewTextBoxCell)row.Cells[3]).Value);

                switch (type)
                {
                case HookType.JAVA:
                {
                    Dictionary <string, JavaParaItem> map = new Dictionary <string, JavaParaItem>();
                    JavaConfig result = new JavaConfig(className, functionName, param, paramCount);
                    for (int i = 4; i < grid.Columns.Count; i++)
                    {
                        DataGridViewColumn       col  = grid.Columns[i];
                        DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)row.Cells[col.Index];
                        if (cell.Tag == null)
                        {
                            cell.Tag = new JavaParaItem();
                        }
                        map.Add(col.Name, (JavaParaItem)cell.Tag);
                    }
                    result.ParamConfig.Add(map);
                    results.Add(result);
                }
                break;

                case HookType.NATIVE:
                {
                    Dictionary <string, NativeParaItem> map = new Dictionary <string, NativeParaItem>();
                    NativeConfig result = new NativeConfig(className, functionName);
                    for (int i = 4; i < grid.Columns.Count; i++)
                    {
                        DataGridViewColumn       col  = grid.Columns[i];
                        DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)row.Cells[col.Index];
                        if (cell.Tag == null)
                        {
                            cell.Tag = new NativeParaItem();
                        }
                        map.Add(col.Name, (NativeParaItem)cell.Tag);
                    }
                    result.ParamConfig.Add(map);
                    results.Add(result);
                }
                break;

                default:
                    break;
                }
            }

            return(results);
        }