Add Linux Minecraft location

This commit is contained in:
teambob 2023-12-25 17:48:15 +11:00 committed by GitHub
parent 15b1b2891f
commit 2140894905
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -257,20 +257,24 @@ namespace NBTExplorer.Windows
return; return;
try { try {
string path = Environment.ExpandEnvironmentVariables("%APPDATA%"); foreach (string path in new[] {
Environment.ExpandEnvironmentVariables("%APPDATA%"),
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) } // Tries Linux Minecraft location
) {
if (!Directory.Exists(path)) { if (!Directory.Exists(path)) {
path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); continue;
} }
path = Path.Combine(path, ".minecraft"); path = Path.Combine(path, ".minecraft", "saves");
path = Path.Combine(path, "saves");
if (!Directory.Exists(path)) { if (!Directory.Exists(path)) {
path = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer); continue;
} }
OpenPaths(new string[] { path }); OpenPaths(new string[] { path });
} }
}
catch (Exception e) { catch (Exception e) {
MessageBox.Show("Could not open default Minecraft save directory"); MessageBox.Show("Could not open default Minecraft save directory");
Console.WriteLine(e.Message); Console.WriteLine(e.Message);