From 0ed5f3e98eb90d5c7fbdc1cdf726c139c46a9ecf Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 23 Nov 2016 20:44:49 -0500 Subject: fix compatibility with mods which use the previous signature of Command.CallCommand --- src/StardewModdingAPI/Command.cs | 10 ++++++++++ src/StardewModdingAPI/Program.cs | 8 ++++++++ 2 files changed, 18 insertions(+) (limited to 'src/StardewModdingAPI') 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 { @@ -66,6 +67,15 @@ namespace StardewModdingAPI /**** ** SMAPI ****/ + /// Parse a command string and invoke it if valid. + /// The command to run, including the command name and any arguments. + [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()); + } + /// Parse a command string and invoke it if valid. /// The command to run, including the command name and any arguments. /// Encapsulates monitoring and logging. 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 } } + /// Get a monitor for legacy code which doesn't have one passed in. + [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 -- cgit