summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/CommandManager.cs9
-rw-r--r--src/StardewModdingAPI/Framework/DeprecationManager.cs18
-rw-r--r--src/StardewModdingAPI/Framework/Models/Manifest.cs2
-rw-r--r--src/StardewModdingAPI/IManifest.cs2
-rw-r--r--src/StardewModdingAPI/Mod.cs4
-rw-r--r--src/StardewModdingAPI/Program.cs8
6 files changed, 12 insertions, 31 deletions
diff --git a/src/StardewModdingAPI/Framework/CommandManager.cs b/src/StardewModdingAPI/Framework/CommandManager.cs
index 9af3d27a..79a23d03 100644
--- a/src/StardewModdingAPI/Framework/CommandManager.cs
+++ b/src/StardewModdingAPI/Framework/CommandManager.cs
@@ -52,8 +52,7 @@ namespace StardewModdingAPI.Framework
public Command Get(string name)
{
name = this.GetNormalisedName(name);
- Command command;
- this.Commands.TryGetValue(name, out command);
+ this.Commands.TryGetValue(name, out Command command);
return command;
}
@@ -92,8 +91,7 @@ namespace StardewModdingAPI.Framework
return false;
// get command
- Command command;
- if (this.Commands.TryGetValue(name, out command))
+ if (this.Commands.TryGetValue(name, out Command command))
{
command.Callback.Invoke(name, arguments);
return true;
@@ -101,6 +99,7 @@ namespace StardewModdingAPI.Framework
return false;
}
+
/*********
** Private methods
*********/
@@ -114,4 +113,4 @@ namespace StardewModdingAPI.Framework
: null;
}
}
-} \ No newline at end of file
+}
diff --git a/src/StardewModdingAPI/Framework/DeprecationManager.cs b/src/StardewModdingAPI/Framework/DeprecationManager.cs
index 43e82d74..b07c6c7d 100644
--- a/src/StardewModdingAPI/Framework/DeprecationManager.cs
+++ b/src/StardewModdingAPI/Framework/DeprecationManager.cs
@@ -1,6 +1,5 @@
-using System;
+using System;
using System.Collections.Generic;
-using System.Reflection;
namespace StardewModdingAPI.Framework
{
@@ -52,10 +51,6 @@ namespace StardewModdingAPI.Framework
if (!this.MarkWarned(source ?? "<unknown>", nounPhrase, version))
return;
- // show SMAPI 2.0 meta-warning
- if(this.MarkWarned("SMAPI", "SMAPI 2.0 meta-warning", "2.0"))
- this.Monitor.Log("Some mods may stop working in SMAPI 2.0 (but they'll work fine for now). Try updating mods with 'deprecated code' warnings; if that doesn't remove the warnings, let the mod authors know about this message or see http://stardewvalleywiki.com/Modding:SMAPI_2.0 for details.", LogLevel.Warn);
-
// build message
string message = $"{source ?? "An unknown mod"} uses deprecated code ({nounPhrase}).";
if (source == null)
@@ -106,16 +101,5 @@ namespace StardewModdingAPI.Framework
this.LoggedDeprecations.Add(key);
return true;
}
-
- /// <summary>Get whether a type implements the given virtual method.</summary>
- /// <param name="subtype">The type to check.</param>
- /// <param name="baseType">The base type which declares the virtual method.</param>
- /// <param name="name">The method name.</param>
- /// <param name="argumentTypes">The expected argument types.</param>
- internal bool IsVirtualMethodImplemented(Type subtype, Type baseType, string name, Type[] argumentTypes)
- {
- MethodInfo method = subtype.GetMethod(nameof(Mod.Entry), argumentTypes);
- return method.DeclaringType != baseType;
- }
}
}
diff --git a/src/StardewModdingAPI/Framework/Models/Manifest.cs b/src/StardewModdingAPI/Framework/Models/Manifest.cs
index a051354c..b85787e5 100644
--- a/src/StardewModdingAPI/Framework/Models/Manifest.cs
+++ b/src/StardewModdingAPI/Framework/Models/Manifest.cs
@@ -27,7 +27,7 @@ namespace StardewModdingAPI.Framework.Models
[JsonConverter(typeof(SFieldConverter))]
public ISemanticVersion MinimumApiVersion { get; set; }
- /// <summary>The name of the DLL in the directory that has the <see cref="Mod.Entry"/> method.</summary>
+ /// <summary>The name of the DLL in the directory that has the <see cref="IMod.Entry"/> method.</summary>
public string EntryDll { get; set; }
/// <summary>The other mods that must be loaded before this mod.</summary>
diff --git a/src/StardewModdingAPI/IManifest.cs b/src/StardewModdingAPI/IManifest.cs
index befef901..9db1d538 100644
--- a/src/StardewModdingAPI/IManifest.cs
+++ b/src/StardewModdingAPI/IManifest.cs
@@ -26,7 +26,7 @@ namespace StardewModdingAPI
/// <summary>The unique mod ID.</summary>
string UniqueID { get; }
- /// <summary>The name of the DLL in the directory that has the <see cref="Mod.Entry"/> method.</summary>
+ /// <summary>The name of the DLL in the directory that has the <see cref="IMod.Entry"/> method.</summary>
string EntryDll { get; }
/// <summary>The other mods that must be loaded before this mod.</summary>
diff --git a/src/StardewModdingAPI/Mod.cs b/src/StardewModdingAPI/Mod.cs
index c511ce5a..ee75ba54 100644
--- a/src/StardewModdingAPI/Mod.cs
+++ b/src/StardewModdingAPI/Mod.cs
@@ -3,7 +3,7 @@ using System;
namespace StardewModdingAPI
{
/// <summary>The base class for a mod.</summary>
- public class Mod : IMod, IDisposable
+ public abstract class Mod : IMod, IDisposable
{
/*********
** Accessors
@@ -23,7 +23,7 @@ namespace StardewModdingAPI
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
- public virtual void Entry(IModHelper helper) { }
+ public abstract void Entry(IModHelper helper);
/// <summary>Release or reset unmanaged resources.</summary>
public void Dispose()
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index 0b58756e..ba8c7847 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -781,8 +781,6 @@ namespace StardewModdingAPI
{
IMod mod = metadata.Mod;
mod.Entry(mod.Helper);
- if (!this.DeprecationManager.IsVirtualMethodImplemented(mod.GetType(), typeof(Mod), nameof(Mod.Entry), new[] { typeof(IModHelper) }))
- this.Monitor.Log($"{metadata.DisplayName} doesn't implement Entry() and may not work correctly.", LogLevel.Error);
}
catch (Exception ex)
{
@@ -816,8 +814,8 @@ namespace StardewModdingAPI
}
// reset cache now if any editors or loaders were added during entry
- IAssetEditor[] editors = loadedMods.SelectMany(p => ((ContentHelper)p.Mod.Helper.Content).AssetEditors).ToArray();
- IAssetLoader[] loaders = loadedMods.SelectMany(p => ((ContentHelper)p.Mod.Helper.Content).AssetLoaders).ToArray();
+ IAssetEditor[] editors = loadedMods.SelectMany(p => p.Mod.Helper.Content.AssetEditors).ToArray();
+ IAssetLoader[] loaders = loadedMods.SelectMany(p => p.Mod.Helper.Content.AssetLoaders).ToArray();
if (editors.Any() || loaders.Any())
{
this.Monitor.Log("Invalidating cached assets for new editors & loaders...", LogLevel.Trace);
@@ -866,7 +864,7 @@ namespace StardewModdingAPI
case "help":
if (arguments.Any())
{
- Framework.Command result = this.CommandManager.Get(arguments[0]);
+ Command result = this.CommandManager.Get(arguments[0]);
if (result == null)
this.Monitor.Log("There's no command with that name.", LogLevel.Error);
else