Skip to content

Commit

Permalink
Fix MinecraftInstanceParser
Browse files Browse the repository at this point in the history
  • Loading branch information
natsurainko committed Sep 3, 2024
1 parent f22d957 commit 3bb5197
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ public class OptiFineInstallData
public required string FileName { get; set; }

[JsonPropertyName("forge")]
public required string ForgeVersion { get; set; }
public string? ForgeVersion { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class MinecraftInstanceParser
/// Successfully parsed instances
/// </summary>
public IReadOnlyCollection<MinecraftInstance> ParsedInstances => _parsedInstances;
private readonly List<MinecraftInstance> _parsedInstances = new();
private readonly List<MinecraftInstance> _parsedInstances = [];

/// <summary>
/// Erroneous directories that failed to parse
/// </summary>
public IReadOnlyCollection<DirectoryInfo> ErroneousDirectories => _erroneousDirectories;
private readonly List<DirectoryInfo> _erroneousDirectories = new();
private readonly List<DirectoryInfo> _erroneousDirectories = [];

// .minecraft folder path
private readonly string _minecraftFolderPath;
Expand All @@ -48,6 +48,9 @@ public MinecraftInstanceParser(string minecraftFolderPath)
/// <returns>All Minecraft instances parsed in this .minecraft profile</returns>
public IReadOnlyCollection<MinecraftInstance> ParseAllInstances()
{
_parsedInstances.Clear();
_erroneousDirectories.Clear();

var versionsDirectory = new DirectoryInfo(Path.Combine(_minecraftFolderPath, "versions"));

if (!versionsDirectory.Exists)
Expand Down

0 comments on commit 3bb5197

Please sign in to comment.