namespace Mlaumcherb.Client.Avalonia.классы;

public class JavaArguments : ArgumentsWithPlaceholders
{
    private static readonly string[] _initial_arguments =
    [
        "-XX:+UnlockExperimentalVMOptions",
        "-XX:+UseG1GC",
        "-XX:G1NewSizePercent=20",
        "-XX:G1ReservePercent=20",
        "-XX:MaxGCPauseMillis=50",
        "-XX:G1HeapRegionSize=32M",
        "-XX:+DisableExplicitGC",
        "-XX:+AlwaysPreTouch",
        "-XX:+ParallelRefProcEnabled",
        "-Xms${xms}M",
        "-Xmx${xmx}M",
        "-Dfile.encoding=UTF-8",
        "-Dlog4j.configurationFile=${path}",
        "-Djava.library.path=${natives_directory}",
        "-Dminecraft.client.jar=${client_jar}",
        "-Dminecraft.launcher.brand=${launcher_name}",
        "-Dminecraft.launcher.version=${launcher_version}",
    ];

    private static readonly string[] _enabled_features = 
    [
    ];

    public JavaArguments(GameVersionDescriptor d)
    {
        _raw_args.AddRange(_initial_arguments);
        if (d.arguments is not null)
        {
            foreach (var av in d.arguments.jvm)
            {
                if (Rules.Check(av.rules, _enabled_features))
                {
                    foreach (var arg in av.value)
                    {
                        // if(!_raw_args.Contains(arg))
                            _raw_args.Add(arg);
                    }
                }
            }
        }

        if (!_raw_args.Contains("-cp"))
        {
            _raw_args.Add("-cp");
            _raw_args.Add("${classpath}");
        }
    }
}
