summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-01-19 11:07:48 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-01-19 11:07:48 -0500
commitba590b20a6581323ac13fc63d380524789d49c97 (patch)
treeb530efe47e72ebe3bc07ccf0503f74eadfca27ec /src/StardewModdingAPI/Framework
parent4fe123350c8946ea9da4269063c30a41aaca87e3 (diff)
downloadSMAPI-ba590b20a6581323ac13fc63d380524789d49c97.tar.gz
SMAPI-ba590b20a6581323ac13fc63d380524789d49c97.tar.bz2
SMAPI-ba590b20a6581323ac13fc63d380524789d49c97.zip
add public mod registry (#220)
Diffstat (limited to 'src/StardewModdingAPI/Framework')
-rw-r--r--src/StardewModdingAPI/Framework/ModRegistry.cs29
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)