diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-01-19 12:23:40 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-01-19 12:23:40 -0500 |
commit | e9cb691251668af87f25549fdedaf382e820075f (patch) | |
tree | 4050e29fc79c54877de5d2ecf905a5befcd512e2 /src/StardewModdingAPI/Framework | |
parent | 6adf199987a506f8a65f6c1ddfad5aa9fa2a6a9f (diff) | |
parent | b90387668d5fee2ebf67d730dbb3aa8cec6a5b67 (diff) | |
download | SMAPI-e9cb691251668af87f25549fdedaf382e820075f.tar.gz SMAPI-e9cb691251668af87f25549fdedaf382e820075f.tar.bz2 SMAPI-e9cb691251668af87f25549fdedaf382e820075f.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r-- | src/StardewModdingAPI/Framework/ModRegistry.cs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Framework/ModRegistry.cs b/src/StardewModdingAPI/Framework/ModRegistry.cs index 51ec7123..209f1928 100644 --- a/src/StardewModdingAPI/Framework/ModRegistry.cs +++ b/src/StardewModdingAPI/Framework/ModRegistry.cs @@ -7,7 +7,7 @@ using System.Reflection; namespace StardewModdingAPI.Framework { /// <summary>Tracks the installed mods.</summary> - internal class ModRegistry + internal class ModRegistry : IModRegistry { /********* ** Properties @@ -22,6 +22,33 @@ namespace StardewModdingAPI.Framework /********* ** Public methods *********/ + /**** + ** IModRegistry + ****/ + /// <summary>Get metadata for all loaded mods.</summary> + public IEnumerable<IManifest> GetAll() + { + return this.Mods.Select(p => p.ModManifest); + } + + /// <summary>Get metadata for a loaded mod.</summary> + /// <param name="uniqueID">The mod's unique ID.</param> + /// <returns>Returns the matching mod's metadata, or <c>null</c> if not found.</returns> + public IManifest Get(string uniqueID) + { + return this.GetAll().FirstOrDefault(p => p.UniqueID == uniqueID); + } + + /// <summary>Get whether a mod has been loaded.</summary> + /// <param name="uniqueID">The mod's unique ID.</param> + public bool IsLoaded(string uniqueID) + { + return this.GetAll().Any(p => p.UniqueID == uniqueID); + } + + /**** + ** Internal methods + ****/ /// <summary>Register a mod as a possible source of deprecation warnings.</summary> /// <param name="mod">The mod instance.</param> public void Add(IMod mod) |