diff --git a/src/SMAPI/Events/ChangeType.cs b/src/SMAPI/Events/ChangeType.cs deleted file mode 100644 index 0fc717df..00000000 --- a/src/SMAPI/Events/ChangeType.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace StardewModdingAPI.Events -{ - /// Indicates how an inventory item changed. - public enum ChangeType - { - /// The entire stack was removed. - Removed, - - /// The entire stack was added. - Added, - - /// The stack size changed. - StackChange - } -} diff --git a/src/SMAPI/Framework/CommandManager.cs b/src/SMAPI/Framework/CommandManager.cs index df798b0c..80c08f34 100644 --- a/src/SMAPI/Framework/CommandManager.cs +++ b/src/SMAPI/Framework/CommandManager.cs @@ -36,11 +36,10 @@ namespace StardewModdingAPI.Framework /// The command name, which the user must type to trigger it. /// The human-readable documentation shown when the player runs the built-in 'help' command. /// The method to invoke when the command is triggered. This method is passed the command name and arguments submitted by the user. - /// Whether to allow a null argument; this should only used for backwards compatibility. /// The or is null or empty. /// The is not a valid format. /// There's already a command with that name. - public CommandManager Add(IModMetadata mod, string name, string documentation, Action callback, bool allowNullCallback = false) + public CommandManager Add(IModMetadata mod, string name, string documentation, Action callback) { name = this.GetNormalizedName(name); @@ -49,7 +48,7 @@ namespace StardewModdingAPI.Framework throw new ArgumentNullException(nameof(name), "Can't register a command with no name."); if (name.Any(char.IsWhiteSpace)) throw new FormatException($"Can't register the '{name}' command because the name can't contain whitespace."); - if (callback == null && !allowNullCallback) + if (callback == null) throw new ArgumentNullException(nameof(callback), $"Can't register the '{name}' command because without a callback."); // ensure uniqueness diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs index 2842c11a..4fdeefbc 100644 --- a/src/SMAPI/Framework/ModLoading/ModResolver.cs +++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs @@ -394,22 +394,6 @@ namespace StardewModdingAPI.Framework.ModLoading } } - /// Get all mod folders in a root folder, passing through empty folders as needed. - /// The root folder path to search. - private IEnumerable GetModFolders(string rootPath) - { - foreach (string modRootPath in Directory.GetDirectories(rootPath)) - { - DirectoryInfo directory = new(modRootPath); - - // if a folder only contains another folder, check the inner folder instead - while (!directory.GetFiles().Any() && directory.GetDirectories().Length == 1) - directory = directory.GetDirectories().First(); - - yield return directory; - } - } - /// Get the dependencies declared in a manifest. /// The mod manifest. /// The loaded mods. diff --git a/src/SMAPI/Framework/Reflection/Reflector.cs b/src/SMAPI/Framework/Reflection/Reflector.cs index d5938c3f..c6fc2c79 100644 --- a/src/SMAPI/Framework/Reflection/Reflector.cs +++ b/src/SMAPI/Framework/Reflection/Reflector.cs @@ -1,7 +1,6 @@ #nullable disable using System; -using System.Linq; using System.Reflection; using System.Runtime.Caching; @@ -128,41 +127,6 @@ namespace StardewModdingAPI.Framework.Reflection return method; } - /**** - ** Methods by signature - ****/ - /// Get a instance method. - /// The object which has the method. - /// The field name. - /// The argument types of the method signature to find. - /// Whether to throw an exception if the field is not found. - public IReflectedMethod GetMethod(object obj, string name, Type[] argumentTypes, bool required = true) - { - // validate parent - if (obj == null) - throw new ArgumentNullException(nameof(obj), "Can't get a instance method from a null object."); - - // get method from hierarchy - ReflectedMethod method = this.GetMethodFromHierarchy(obj.GetType(), obj, name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, argumentTypes); - if (required && method == null) - throw new InvalidOperationException($"The {obj.GetType().FullName} object doesn't have a '{name}' instance method with that signature."); - return method; - } - - /// Get a static method. - /// The type which has the method. - /// The field name. - /// The argument types of the method signature to find. - /// Whether to throw an exception if the field is not found. - public IReflectedMethod GetMethod(Type type, string name, Type[] argumentTypes, bool required = true) - { - // get field from hierarchy - ReflectedMethod method = this.GetMethodFromHierarchy(type, null, name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static, argumentTypes); - if (required && method == null) - throw new InvalidOperationException($"The {type.FullName} object doesn't have a '{name}' static method with that signature."); - return method; - } - /********* ** Private methods @@ -232,27 +196,6 @@ namespace StardewModdingAPI.Framework.Reflection : null; } - /// Get a method from the type hierarchy. - /// The type which has the method. - /// The object which has the method. - /// The method name. - /// The reflection binding which flags which indicates what type of method to find. - /// The argument types of the method signature to find. - private ReflectedMethod GetMethodFromHierarchy(Type type, object obj, string name, BindingFlags bindingFlags, Type[] argumentTypes) - { - bool isStatic = bindingFlags.HasFlag(BindingFlags.Static); - MethodInfo method = this.GetCached($"method::{isStatic}::{type.FullName}::{name}({string.Join(",", argumentTypes.Select(p => p.FullName))})", () => - { - MethodInfo methodInfo = null; - for (; type != null && methodInfo == null; type = type.BaseType) - methodInfo = type.GetMethod(name, bindingFlags, null, argumentTypes, null); - return methodInfo; - }); - return method != null - ? new ReflectedMethod(type, obj, method, isStatic) - : null; - } - /// Get a method or field through the cache. /// The expected type. /// The cache key. diff --git a/src/SMAPI/Framework/RequestExitDelegate.cs b/src/SMAPI/Framework/RequestExitDelegate.cs deleted file mode 100644 index 93ef1cf9..00000000 --- a/src/SMAPI/Framework/RequestExitDelegate.cs +++ /dev/null @@ -1,9 +0,0 @@ -#nullable disable - -namespace StardewModdingAPI.Framework -{ - /// A delegate which requests that SMAPI immediately exit the game. This should only be invoked when an irrecoverable fatal error happens that risks save corruption or game-breaking bugs. - /// The module which requested an immediate exit. - /// The reason provided for the shutdown. - internal delegate void RequestExitDelegate(string module, string reason); -} diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs index 4fa7fe7b..0a8a068f 100644 --- a/src/SMAPI/Framework/SGame.cs +++ b/src/SMAPI/Framework/SGame.cs @@ -2,7 +2,6 @@ using System; using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.Text; -using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Events; @@ -64,9 +63,6 @@ namespace StardewModdingAPI.Framework /// Manages input visible to the game. public SInputState Input => (SInputState)Game1.input; - /// The game background task which initializes a new day. - public Task NewDayTask => Game1._newDayTask; - /// Monitors the entire game state for changes. public WatcherCore Watchers { get; private set; } = null!; // initialized on first update tick