diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-13 20:41:00 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-05-13 20:41:00 -0400 |
commit | 7f368aa8896baa551aa156a8e67e9dd16416022d (patch) | |
tree | c741e209e0161e3234d86559febce0e83d2e5a42 | |
parent | 9b6c0d1021b07ec04b589f1bd0eb69e36082b600 (diff) | |
download | SMAPI-7f368aa8896baa551aa156a8e67e9dd16416022d.tar.gz SMAPI-7f368aa8896baa551aa156a8e67e9dd16416022d.tar.bz2 SMAPI-7f368aa8896baa551aa156a8e67e9dd16416022d.zip |
enforce metadata.SetStatus() instead of setting properties directly (#285)
-rw-r--r-- | src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs | 4 | ||||
-rw-r--r-- | src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs | 6 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 8 |
3 files changed, 6 insertions, 12 deletions
diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs index 7be85a83..5ec2d4e0 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModMetadata.cs @@ -21,10 +21,10 @@ namespace StardewModdingAPI.Framework.ModLoading public ModCompatibility Compatibility { get; } /// <summary>The metadata resolution status.</summary> - public ModMetadataStatus Status { get; set; } + public ModMetadataStatus Status { get; private set; } /// <summary>The reason the metadata is invalid, if any.</summary> - public string Error { get; set; } + public string Error { get; private set; } /********* diff --git a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs index 829575af..9b26e8b0 100644 --- a/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs +++ b/src/StardewModdingAPI/Framework/ModLoading/ModResolver.cs @@ -188,8 +188,7 @@ namespace StardewModdingAPI.Framework.ModLoading } if (missingMods != null) { - mod.Status = ModMetadataStatus.Failed; - mod.Error = $"it requires mods which aren't installed ({missingMods.Substring(0, missingMods.Length - 2)})."; + mod.SetStatus(ModMetadataStatus.Failed, $"it requires mods which aren't installed ({missingMods.Substring(0, missingMods.Length - 2)})."); return false; } } @@ -207,8 +206,7 @@ namespace StardewModdingAPI.Framework.ModLoading ModMetadata circularReferenceMod = currentChain.FirstOrDefault(modsToLoadFirst.Contains); if (circularReferenceMod != null) { - mod.Status = ModMetadataStatus.Failed; - mod.Error = $"its dependencies have a circular reference: {string.Join(" => ", currentChain.Select(p => p.DisplayName))} => {circularReferenceMod.DisplayName})."; + mod.SetStatus(ModMetadataStatus.Failed, $"its dependencies have a circular reference: {string.Join(" => ", currentChain.Select(p => p.DisplayName))} => {circularReferenceMod.DisplayName})."); return false; } currentChain.Add(mod); diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 74a9ff8e..37e1e000 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -337,15 +337,11 @@ namespace StardewModdingAPI string psDir = Path.Combine(mod.DirectoryPath, "psconfigs"); Directory.CreateDirectory(psDir); if (!Directory.Exists(psDir)) - { - mod.Status = ModMetadataStatus.Failed; - mod.Error = "it requires per-save configuration files ('psconfigs') which couldn't be created for some reason."; - } + mod.SetStatus(ModMetadataStatus.Failed, "it requires per-save configuration files ('psconfigs') which couldn't be created for some reason."); } catch (Exception ex) { - mod.Status = ModMetadataStatus.Failed; - mod.Error = $"it requires per-save configuration files ('psconfigs') which couldn't be created: {ex.GetLogSummary()}"; + mod.SetStatus(ModMetadataStatus.Failed, $"it requires per-save configuration files ('psconfigs') which couldn't be created: {ex.GetLogSummary()}"); } } } |