Skip to content

Search inside of server folder for java runtimes #32

Description

@flleeppyy

Is your feature request related to a problem? Please describe.
Hiya, could you add functionality to the JavaPathPicker form to search in the directory of the server? Some modpack server installs come bundled with java runtimes, or allow you to install one and it'll install it into the server directory.

Describe the solution you'd like
New param to FindJavaInstallations for additional directories to search, then when calling the function from FrmInstanceEdit, pass the path of the server.

something like this? can't test but would work in theory! just combining potentialInstalledJavaLocations with the passed in args for additional directories.

public Dictionary<string, string> FindJavaInstallations(params string[] additionalDirectories)
{
	List<string> potentialInstalledJavaLocations = Globals.McssSettings.PotentialInstalledJavaLocations;
	if (potentialInstalledJavaLocations == null || potentialInstalledJavaLocations.Count <= 0)
	{
		Globals.McssSettings.ResetPotentialInstalledJavaLocations();
		return this.FindJavaInstallations(additionalDirectories);
	}

	try
	{
		List<string> searchDirectories = new List<string>(potentialInstalledJavaLocations);

		if (additionalDirectories != null)
		{
			searchDirectories.AddRange(additionalDirectories);
		}

		Dictionary<string, string> dictionary = new Dictionary<string, string>();

		// rest of the inplementation here
}
new FrmJavaPathPicker(this._logic.FindJavaInstallations(this.server.path), this.txtLocalJavaVariablePath.Value))

though, i would rearrange the code to do like

List<string> searchDirectories = new List<string>()
if (additionalDirectories != null)
{
	searchDirectories.AddRange(additionalDirectories);
}
searchDirectories.AddRange(potentialInstalledJavaLocations);

so that the passed directory is searched and appended to the results first rather than last.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions