using System; using System.Collections.Generic; using StardewModdingAPI.Events; namespace StardewModdingAPI { /// Provides simplified APIs for writing mods. public interface IModHelper { /********* ** Accessors *********/ /// The full path to the mod's folder. string DirectoryPath { get; } /// Manages access to events raised by SMAPI, which let your mod react when something happens in the game. IModEvents Events { get; } /// An API for managing console commands. ICommandHelper ConsoleCommands { get; } /// An API for loading content assets. IContentHelper Content { get; } /// An API for reading and writing persistent mod data. IDataHelper Data { get; } /// An API for checking and changing input state. IInputHelper Input { get; } /// Simplifies access to private game code. IReflectionHelper Reflection { get; } /// Metadata about loaded mods. IModRegistry ModRegistry { get; } /// Provides multiplayer utilities. IMultiplayerHelper Multiplayer { get; } /// Provides translations stored in the mod's i18n folder, with one file per locale (like en.json) containing a flat key => value structure. Translations are fetched with locale fallback, so missing translations are filled in from broader locales (like pt-BR.json < pt.json < default.json). ITranslationHelper Translation { get; } /********* ** Public methods *********/ /**** ** Mod config file ****/ /// Read the mod's configuration file (and create it if needed). /// The config class type. This should be a plain class that has public properties for the settings you want. These can be complex types. TConfig ReadConfig() where TConfig : class, new(); /// Save to the mod's configuration file. /// The config class type. /// The config settings to save. void WriteConfig(TConfig config) where TConfig : class, new(); #if !SMAPI_3_0_STRICT /**** ** Generic JSON files ****/ /// Read a JSON file. /// The model type. /// The file path relative to the mod directory. /// Returns the deserialised model, or null if the file doesn't exist or is empty. [Obsolete("Use " + nameof(IModHelper.Data) + "." + nameof(IDataHelper.ReadJsonFile) + " instead")] TModel ReadJsonFile(string path) where TModel : class; /// Save to a JSON file. /// The model type. /// The file path relative to the mod directory. /// The model to save. [Obsolete("Use " + nameof(IModHelper.Data) + "." + nameof(IDataHelper.WriteJsonFile) + " instead")] void WriteJsonFile(string path, TModel model) where TModel : class; #endif /**** ** Content packs ****/ /// Create a temporary content pack to read files from a directory. Temporary content packs will not appear in the SMAPI log and update checks will not be performed. /// The absolute directory path containing the content pack files. /// The content pack's unique ID. /// The content pack name. /// The content pack description. /// The content pack author's name. /// The content pack version. IContentPack CreateTemporaryContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); #if !SMAPI_3_0_STRICT /// Manually create a transitional content pack to support pre-SMAPI content packs. This provides a way to access legacy content packs using the SMAPI content pack APIs, but the content pack will not be visible in the log or validated by SMAPI. /// The absolute directory path containing the content pack files. /// The content pack's unique ID. /// The content pack name. /// The content pack description. /// The content pack author's name. /// The content pack version. [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.CreateTemporaryContentPack) + " instead")] IContentPack CreateTransitionalContentPack(string directoryPath, string id, string name, string description, string author, ISemanticVersion version); #endif /// Get all content packs loaded for this mod. IEnumerable GetContentPacks(); } }