From c37280222dac3409f78413d90c8e50f6d410b3d1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 23 Aug 2020 20:53:09 -0400 Subject: [PATCH] minor cleanup --- src/SMAPI.Installer/Enums/ScriptAction.cs | 2 +- src/SMAPI.Installer/InteractiveInstaller.cs | 3 +-- src/SMAPI.Installer/Program.cs | 2 -- src/SMAPI/Events/ChangeType.cs | 2 +- src/SMAPI/Events/WarpedEventArgs.cs | 1 - src/SMAPI/Framework/CommandManager.cs | 1 + src/SMAPI/Framework/ContentCoordinator.cs | 1 - .../ContentManagers/BaseContentManager.cs | 2 +- src/SMAPI/Framework/DeprecationLevel.cs | 2 +- src/SMAPI/Framework/DeprecationManager.cs | 1 + src/SMAPI/Framework/Events/ModGameLoopEvents.cs | 1 - src/SMAPI/Framework/InternalExtensions.cs | 4 ++-- src/SMAPI/Framework/ModHelpers/ModHelper.cs | 1 - src/SMAPI/Framework/RequestExitDelegate.cs | 2 +- src/SMAPI/Framework/SCore.cs | 14 +++++++++----- .../StateTracking/Snapshots/PlayerSnapshot.cs | 1 - src/SMAPI/Framework/Utilities/Countdown.cs | 2 +- src/SMAPI/IReflectedField.cs | 2 +- src/SMAPI/IReflectedMethod.cs | 2 +- src/SMAPI/Program.cs | 1 + src/SMAPI/Utilities/SDate.cs | 1 - 21 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/SMAPI.Installer/Enums/ScriptAction.cs b/src/SMAPI.Installer/Enums/ScriptAction.cs index e62b2a7c..27f649a6 100644 --- a/src/SMAPI.Installer/Enums/ScriptAction.cs +++ b/src/SMAPI.Installer/Enums/ScriptAction.cs @@ -9,4 +9,4 @@ /// Remove SMAPI from the game directory. Uninstall } -} \ No newline at end of file +} diff --git a/src/SMAPI.Installer/InteractiveInstaller.cs b/src/SMAPI.Installer/InteractiveInstaller.cs index dc96e2e8..d0ef0b8d 100644 --- a/src/SMAPI.Installer/InteractiveInstaller.cs +++ b/src/SMAPI.Installer/InteractiveInstaller.cs @@ -35,8 +35,6 @@ namespace StardewModdingApi.Installer "SMAPI.ConsoleCommands" }; - - /// Get the absolute file or folder paths to remove when uninstalling SMAPI. /// The folder for Stardew Valley and SMAPI. /// The folder for SMAPI mods. @@ -84,6 +82,7 @@ namespace StardewModdingApi.Installer foreach (DirectoryInfo modDir in modsDir.EnumerateDirectories()) yield return Path.Combine(modDir.FullName, ".cache"); // 1.4–1.7 } + yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs"); // remove old log files } diff --git a/src/SMAPI.Installer/Program.cs b/src/SMAPI.Installer/Program.cs index dc6c97f4..6c479621 100644 --- a/src/SMAPI.Installer/Program.cs +++ b/src/SMAPI.Installer/Program.cs @@ -3,8 +3,6 @@ using System.Diagnostics.CodeAnalysis; using System.IO; using System.IO.Compression; using System.Reflection; -using StardewModdingAPI.Internal; -using StardewModdingAPI.Toolkit.Utilities; namespace StardewModdingApi.Installer { diff --git a/src/SMAPI/Events/ChangeType.cs b/src/SMAPI/Events/ChangeType.cs index 4b207f08..0fc717df 100644 --- a/src/SMAPI/Events/ChangeType.cs +++ b/src/SMAPI/Events/ChangeType.cs @@ -12,4 +12,4 @@ namespace StardewModdingAPI.Events /// The stack size changed. StackChange } -} \ No newline at end of file +} diff --git a/src/SMAPI/Events/WarpedEventArgs.cs b/src/SMAPI/Events/WarpedEventArgs.cs index 95c53ad9..9afe4a4e 100644 --- a/src/SMAPI/Events/WarpedEventArgs.cs +++ b/src/SMAPI/Events/WarpedEventArgs.cs @@ -22,7 +22,6 @@ namespace StardewModdingAPI.Events public bool IsLocalPlayer => this.Player.IsLocalPlayer; - /********* ** Public methods *********/ diff --git a/src/SMAPI/Framework/CommandManager.cs b/src/SMAPI/Framework/CommandManager.cs index 2b91d394..4a99fd4d 100644 --- a/src/SMAPI/Framework/CommandManager.cs +++ b/src/SMAPI/Framework/CommandManager.cs @@ -119,6 +119,7 @@ namespace StardewModdingAPI.Framework command.Callback.Invoke(name, arguments); return true; } + return false; } diff --git a/src/SMAPI/Framework/ContentCoordinator.cs b/src/SMAPI/Framework/ContentCoordinator.cs index 479ffa7f..d1021cad 100644 --- a/src/SMAPI/Framework/ContentCoordinator.cs +++ b/src/SMAPI/Framework/ContentCoordinator.cs @@ -9,7 +9,6 @@ using Microsoft.Xna.Framework.Content; using StardewModdingAPI.Framework.Content; using StardewModdingAPI.Framework.ContentManagers; using StardewModdingAPI.Framework.Reflection; -using StardewModdingAPI.Framework.StateTracking.Comparers; using StardewModdingAPI.Metadata; using StardewModdingAPI.Toolkit.Serialization; using StardewModdingAPI.Toolkit.Utilities; diff --git a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs index a8de013a..6bc3a505 100644 --- a/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/BaseContentManager.cs @@ -76,7 +76,7 @@ namespace StardewModdingAPI.Framework.ContentManagers /// A callback to invoke when the content manager is being disposed. /// Whether this content manager handles managed asset keys (e.g. to load assets from a mod folder). protected BaseContentManager(string name, IServiceProvider serviceProvider, string rootDirectory, CultureInfo currentCulture, ContentCoordinator coordinator, IMonitor monitor, Reflector reflection, Action onDisposing, bool isNamespaced) - : base(serviceProvider, rootDirectory, currentCulture) + : base(serviceProvider, rootDirectory, currentCulture) { // init this.Name = name; diff --git a/src/SMAPI/Framework/DeprecationLevel.cs b/src/SMAPI/Framework/DeprecationLevel.cs index c0044053..12b50952 100644 --- a/src/SMAPI/Framework/DeprecationLevel.cs +++ b/src/SMAPI/Framework/DeprecationLevel.cs @@ -12,4 +12,4 @@ namespace StardewModdingAPI.Framework /// The code will be removed soon. Deprecation messages should be warnings in the console. PendingRemoval } -} \ No newline at end of file +} diff --git a/src/SMAPI/Framework/DeprecationManager.cs b/src/SMAPI/Framework/DeprecationManager.cs index 11fae0b2..94a2da85 100644 --- a/src/SMAPI/Framework/DeprecationManager.cs +++ b/src/SMAPI/Framework/DeprecationManager.cs @@ -107,6 +107,7 @@ namespace StardewModdingAPI.Framework } } } + this.QueuedWarnings.Clear(); } diff --git a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs index a0119bf8..1150d641 100644 --- a/src/SMAPI/Framework/Events/ModGameLoopEvents.cs +++ b/src/SMAPI/Framework/Events/ModGameLoopEvents.cs @@ -96,7 +96,6 @@ namespace StardewModdingAPI.Framework.Events /// Raised after the in-game clock time changes. public event EventHandler TimeChanged { - add => this.EventManager.TimeChanged.Add(value, this.Mod); remove => this.EventManager.TimeChanged.Remove(value); } diff --git a/src/SMAPI/Framework/InternalExtensions.cs b/src/SMAPI/Framework/InternalExtensions.cs index 8b45e196..b6704f26 100644 --- a/src/SMAPI/Framework/InternalExtensions.cs +++ b/src/SMAPI/Framework/InternalExtensions.cs @@ -164,9 +164,9 @@ namespace StardewModdingAPI.Framework // get field name const string fieldName = #if SMAPI_FOR_WINDOWS - "inBeginEndPair"; + "inBeginEndPair"; #else - "_beginCalled"; + "_beginCalled"; #endif // get result diff --git a/src/SMAPI/Framework/ModHelpers/ModHelper.cs b/src/SMAPI/Framework/ModHelpers/ModHelper.cs index 25401e23..9fbb6072 100644 --- a/src/SMAPI/Framework/ModHelpers/ModHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/ModHelper.cs @@ -2,7 +2,6 @@ using System; using System.IO; using StardewModdingAPI.Events; using StardewModdingAPI.Framework.Input; -using StardewModdingAPI.Toolkit.Serialization; namespace StardewModdingAPI.Framework.ModHelpers { diff --git a/src/SMAPI/Framework/RequestExitDelegate.cs b/src/SMAPI/Framework/RequestExitDelegate.cs index 12d0ea0c..810c399b 100644 --- a/src/SMAPI/Framework/RequestExitDelegate.cs +++ b/src/SMAPI/Framework/RequestExitDelegate.cs @@ -4,4 +4,4 @@ namespace StardewModdingAPI.Framework /// The module which requested an immediate exit. /// The reason provided for the shutdown. internal delegate void RequestExitDelegate(string module, string reason); -} \ No newline at end of file +} diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 47a23c87..2346550e 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -43,7 +43,7 @@ using StardewModdingAPI.Toolkit.Serialization; using StardewModdingAPI.Toolkit.Utilities; using StardewModdingAPI.Utilities; using StardewValley; -using Object = StardewValley.Object; +using SObject = StardewValley.Object; namespace StardewModdingAPI.Framework { @@ -524,6 +524,7 @@ namespace StardewModdingAPI.Framework Game1.currentLoader = null; this.Monitor.Log("Game loader done."); } + if (SGame.NewDayTask?.Status == TaskStatus.Created) { this.Monitor.Log("New day task synchronizing..."); @@ -605,7 +606,7 @@ namespace StardewModdingAPI.Framework $"{modGroup.Key.DisplayName} (" + string.Join(", ", modGroup.GroupBy(p => p.WasAdded).ToDictionary(p => p.Key, p => p.Count()).Select(p => $"{(p.Key ? "added" : "removed")} {p.Value}")) + ")" - ) + ) ) ); @@ -700,6 +701,7 @@ namespace StardewModdingAPI.Framework this.OnLoadStageChanged(LoadStage.CreatedSaveFile); events.SaveCreated.RaiseEmpty(); } + if (this.IsBetweenSaveEvents) { // raise after-save @@ -731,6 +733,7 @@ namespace StardewModdingAPI.Framework } else context += " Single-player."; + this.Monitor.Log(context); // raise events @@ -1111,7 +1114,7 @@ namespace StardewModdingAPI.Framework // require core fields string[] fields = entry.Value.Split('/'); - if (fields.Length < Object.objectInfoDescriptionIndex + 1) + if (fields.Length < SObject.objectInfoDescriptionIndex + 1) { LogIssue(entry.Key, "too few fields for an object"); hasObjectIssues = true; @@ -1119,10 +1122,10 @@ namespace StardewModdingAPI.Framework } // check min length for specific types - switch (fields[Object.objectInfoTypeIndex].Split(new[] { ' ' }, 2)[0]) + switch (fields[SObject.objectInfoTypeIndex].Split(new[] { ' ' }, 2)[0]) { case "Cooking": - if (fields.Length < Object.objectInfoBuffDurationIndex + 1) + if (fields.Length < SObject.objectInfoBuffDurationIndex + 1) { LogIssue(entry.Key, "too few fields for a cooking item"); hasObjectIssues = true; @@ -1316,6 +1319,7 @@ namespace StardewModdingAPI.Framework } } } + IModMetadata[] loaded = this.ModRegistry.GetAll().ToArray(); IModMetadata[] loadedContentPacks = loaded.Where(p => p.IsContentPack).ToArray(); IModMetadata[] loadedMods = loaded.Where(p => !p.IsContentPack).ToArray(); diff --git a/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs b/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs index f0fb9485..0908b02a 100644 --- a/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs +++ b/src/SMAPI/Framework/StateTracking/Snapshots/PlayerSnapshot.cs @@ -58,7 +58,6 @@ namespace StardewModdingAPI.Framework.StateTracking.Snapshots this.Inventory = watcher.TryGetInventoryChanges(out SnapshotItemListDiff itemChanges) ? itemChanges : this.EmptyItemListDiff; - } } } diff --git a/src/SMAPI/Framework/Utilities/Countdown.cs b/src/SMAPI/Framework/Utilities/Countdown.cs index 921a35ce..342b4258 100644 --- a/src/SMAPI/Framework/Utilities/Countdown.cs +++ b/src/SMAPI/Framework/Utilities/Countdown.cs @@ -34,7 +34,7 @@ this.Current--; return true; } - + /// Restart the countdown. public void Reset() { diff --git a/src/SMAPI/IReflectedField.cs b/src/SMAPI/IReflectedField.cs index 43ddad42..7ff61f29 100644 --- a/src/SMAPI/IReflectedField.cs +++ b/src/SMAPI/IReflectedField.cs @@ -23,4 +23,4 @@ namespace StardewModdingAPI //// The value to set. void SetValue(TValue value); } -} \ No newline at end of file +} diff --git a/src/SMAPI/IReflectedMethod.cs b/src/SMAPI/IReflectedMethod.cs index de83b98c..646e7301 100644 --- a/src/SMAPI/IReflectedMethod.cs +++ b/src/SMAPI/IReflectedMethod.cs @@ -24,4 +24,4 @@ namespace StardewModdingAPI /// The method arguments to pass in. void Invoke(params object[] arguments); } -} \ No newline at end of file +} diff --git a/src/SMAPI/Program.cs b/src/SMAPI/Program.cs index 05251070..23ee8453 100644 --- a/src/SMAPI/Program.cs +++ b/src/SMAPI/Program.cs @@ -59,6 +59,7 @@ namespace StardewModdingAPI if (name.Name.Equals(AssemblyName.GetAssemblyName(dll.FullName).Name, StringComparison.OrdinalIgnoreCase)) return Assembly.LoadFrom(dll.FullName); } + return null; } catch (Exception ex) diff --git a/src/SMAPI/Utilities/SDate.cs b/src/SMAPI/Utilities/SDate.cs index 165667a4..cd075dcc 100644 --- a/src/SMAPI/Utilities/SDate.cs +++ b/src/SMAPI/Utilities/SDate.cs @@ -269,7 +269,6 @@ namespace StardewModdingAPI.Utilities this.Year = year; this.DayOfWeek = this.GetDayOfWeek(day); this.DaysSinceStart = this.GetDaysSinceStart(day, season, year); - } /// Get whether a date represents 0 spring Y1, which is the date during the in-game intro.