diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Events/ChangeType.cs | 15 | ||||
-rw-r--r-- | src/SMAPI/Framework/CommandManager.cs | 5 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModLoading/ModResolver.cs | 16 | ||||
-rw-r--r-- | src/SMAPI/Framework/Reflection/Reflector.cs | 57 | ||||
-rw-r--r-- | src/SMAPI/Framework/RequestExitDelegate.cs | 9 | ||||
-rw-r--r-- | src/SMAPI/Framework/SGame.cs | 4 |
6 files changed, 2 insertions, 104 deletions
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 -{ - /// <summary>Indicates how an inventory item changed.</summary> - public enum ChangeType - { - /// <summary>The entire stack was removed.</summary> - Removed, - - /// <summary>The entire stack was added.</summary> - Added, - - /// <summary>The stack size changed.</summary> - 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 /// <param name="name">The command name, which the user must type to trigger it.</param> /// <param name="documentation">The human-readable documentation shown when the player runs the built-in 'help' command.</param> /// <param name="callback">The method to invoke when the command is triggered. This method is passed the command name and arguments submitted by the user.</param> - /// <param name="allowNullCallback">Whether to allow a null <paramref name="callback"/> argument; this should only used for backwards compatibility.</param> /// <exception cref="ArgumentNullException">The <paramref name="name"/> or <paramref name="callback"/> is null or empty.</exception> /// <exception cref="FormatException">The <paramref name="name"/> is not a valid format.</exception> /// <exception cref="ArgumentException">There's already a command with that name.</exception> - public CommandManager Add(IModMetadata mod, string name, string documentation, Action<string, string[]> callback, bool allowNullCallback = false) + public CommandManager Add(IModMetadata mod, string name, string documentation, Action<string, string[]> 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 } } - /// <summary>Get all mod folders in a root folder, passing through empty folders as needed.</summary> - /// <param name="rootPath">The root folder path to search.</param> - private IEnumerable<DirectoryInfo> 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; - } - } - /// <summary>Get the dependencies declared in a manifest.</summary> /// <param name="manifest">The mod manifest.</param> /// <param name="loadedMods">The loaded mods.</param> 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 - ****/ - /// <summary>Get a instance method.</summary> - /// <param name="obj">The object which has the method.</param> - /// <param name="name">The field name.</param> - /// <param name="argumentTypes">The argument types of the method signature to find.</param> - /// <param name="required">Whether to throw an exception if the field is not found.</param> - 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; - } - - /// <summary>Get a static method.</summary> - /// <param name="type">The type which has the method.</param> - /// <param name="name">The field name.</param> - /// <param name="argumentTypes">The argument types of the method signature to find.</param> - /// <param name="required">Whether to throw an exception if the field is not found.</param> - 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; } - /// <summary>Get a method from the type hierarchy.</summary> - /// <param name="type">The type which has the method.</param> - /// <param name="obj">The object which has the method.</param> - /// <param name="name">The method name.</param> - /// <param name="bindingFlags">The reflection binding which flags which indicates what type of method to find.</param> - /// <param name="argumentTypes">The argument types of the method signature to find.</param> - 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; - } - /// <summary>Get a method or field through the cache.</summary> /// <typeparam name="TMemberInfo">The expected <see cref="MemberInfo"/> type.</typeparam> /// <param name="key">The cache key.</param> 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 -{ - /// <summary>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.</summary> - /// <param name="module">The module which requested an immediate exit.</param> - /// <param name="reason">The reason provided for the shutdown.</param> - 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 /// <summary>Manages input visible to the game.</summary> public SInputState Input => (SInputState)Game1.input; - /// <summary>The game background task which initializes a new day.</summary> - public Task NewDayTask => Game1._newDayTask; - /// <summary>Monitors the entire game state for changes.</summary> public WatcherCore Watchers { get; private set; } = null!; // initialized on first update tick |