diff options
-rw-r--r-- | src/StardewModdingAPI/Command.cs | 10 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 8 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/Command.cs b/src/StardewModdingAPI/Command.cs index ef4ca2d8..1fa18d49 100644 --- a/src/StardewModdingAPI/Command.cs +++ b/src/StardewModdingAPI/Command.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using StardewModdingAPI.Events; +using StardewModdingAPI.Framework; namespace StardewModdingAPI { @@ -68,6 +69,15 @@ namespace StardewModdingAPI ****/ /// <summary>Parse a command string and invoke it if valid.</summary> /// <param name="input">The command to run, including the command name and any arguments.</param> + [Obsolete("Use the overload which passes in your mod's monitor")] + public static void CallCommand(string input) + { + Program.DeprecationManager.Warn($"an old version of {nameof(Command)}.{nameof(Command.CallCommand)}", "1.1", DeprecationLevel.Notice); + Command.CallCommand(input, Program.GetLegacyMonitorForMod()); + } + + /// <summary>Parse a command string and invoke it if valid.</summary> + /// <param name="input">The command to run, including the command name and any arguments.</param> /// <param name="monitor">Encapsulates monitoring and logging.</param> public static void CallCommand(string input, IMonitor monitor) { diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 0871e98a..14dbafc9 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -161,6 +161,14 @@ namespace StardewModdingAPI } } + /// <summary>Get a monitor for legacy code which doesn't have one passed in.</summary> + [Obsolete("This method should only be used when needed for backwards compatibility.")] + internal static IMonitor GetLegacyMonitorForMod() + { + string modName = Program.ModRegistry.GetModFromStack() ?? "unknown"; + return new Monitor(modName, Program.LogFile); + } + /********* ** Private methods |