using System; #if SMAPI_DEPRECATED using StardewModdingAPI.Framework.Deprecations; #endif namespace StardewModdingAPI.Framework.ModHelpers { /// Provides an API for managing console commands. internal class CommandHelper : BaseHelper, ICommandHelper { /********* ** Fields *********/ /// Manages console commands. private readonly CommandManager CommandManager; /********* ** Public methods *********/ /// Construct an instance. /// The mod using this instance. /// Manages console commands. public CommandHelper(IModMetadata mod, CommandManager commandManager) : base(mod) { this.CommandManager = commandManager; } /// public ICommandHelper Add(string name, string documentation, Action callback) { this.CommandManager.Add(this.Mod, name, documentation, callback); return this; } #if SMAPI_DEPRECATED /// [Obsolete("Use mod-provided APIs to integrate with mods instead. This method will be removed in SMAPI 4.0.0.")] public bool Trigger(string name, string[] arguments) { SCore.DeprecationManager.Warn( source: this.Mod, nounPhrase: $"{nameof(IModHelper)}.{nameof(IModHelper.ConsoleCommands)}.{nameof(ICommandHelper.Trigger)}", version: "3.8.1", severity: DeprecationLevel.Notice ); return this.CommandManager.Trigger(name, arguments); } #endif } }