From 1a5eb12cc6877da6dd95bcae8814bc5d3fb87a9b Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 19 Nov 2016 18:56:35 -0500 Subject: [PATCH] restore obsolete SPlayer for backwards compatibility, mark deprecated --- release-notes.md | 2 +- src/StardewModdingAPI/Entities/SPlayer.cs | 59 +++++++++++++++++++ .../StardewModdingAPI.csproj | 1 + 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/StardewModdingAPI/Entities/SPlayer.cs diff --git a/release-notes.md b/release-notes.md index 2fa17b7f..9f38b269 100644 --- a/release-notes.md +++ b/release-notes.md @@ -7,7 +7,7 @@ For players: * Fixed console exiting immediately when some exceptions occur. * Fixed an error in 1.0 when mod uses `config.json` but the file doesn't exist. * Fixed critical errors being saved to a separate log file. - * Fixed compatibility with mods that use obsolete `Log` methods.1.1.1 + * Fixed compatibility with some older mods.1.1.1, 1.1.2 * Fixed race condition where some mods would sometimes crash because the game wasn't ready yet.1.1.1 For developers: diff --git a/src/StardewModdingAPI/Entities/SPlayer.cs b/src/StardewModdingAPI/Entities/SPlayer.cs new file mode 100644 index 00000000..66c7ba44 --- /dev/null +++ b/src/StardewModdingAPI/Entities/SPlayer.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using StardewModdingAPI.Framework; +using StardewValley; + +namespace StardewModdingAPI.Entities +{ + /// Static class for integrating with the player. + [Obsolete("This API was never officially documented and will be removed soon.")] + public class SPlayer + { + /********* + ** Accessors + *********/ + /// Obsolete. + [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.getAllFarmers) + " instead")] + public static List AllFarmers + { + get + { + Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); + return Game1.getAllFarmers(); + } + } + + /// Obsolete. + [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.player) + " instead")] + public static Farmer CurrentFarmer + { + get + { + Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); + return Game1.player; + } + } + + /// Obsolete. + [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.player) + " instead")] + public static Farmer Player + { + get + { + Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); + return Game1.player; + } + } + + /// Obsolete. + [Obsolete("Use " + nameof(Game1) + "." + nameof(Game1.player) + "." + nameof(Farmer.currentLocation) + " instead")] + public static GameLocation CurrentFarmerLocation + { + get + { + Program.DeprecationManager.Warn(nameof(SPlayer), "1.0", DeprecationLevel.Info); + return Game1.player.currentLocation; + } + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj index 7b28a63e..e0608cce 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.csproj +++ b/src/StardewModdingAPI/StardewModdingAPI.csproj @@ -166,6 +166,7 @@ +