SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

Better handle duplicate mods

Pathoschild opened this issue ยท 6 comments

commented

When the player has multiple copies of the same mod, SMAPI loads the first one and then shows an error like this for the second:

Skipped Trainer Mod because its DLL 'TrainerMod.dll' couldn't be loaded:
System.InvalidOperationException: Could not load 'C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods\TrainerMod\TrainerMod.dll' because it doesn't exist.
   at StardewModdingAPI.Framework.ModLoading.AssemblyLoader.Load(String assemblyPath, Boolean assumeCompatible) in D:\source\_Stardew\SMAPI\src\StardewModdingAPI\Framework\ModLoading\AssemblyLoader.cs:line 69
   at StardewModdingAPI.Program.LoadMods(IModMetadata[] mods, JsonHelper jsonHelper, SContentManager contentManager, IList`1 deprecationWarnings) in D:\source\_Stardew\SMAPI\src\StardewModdingAPI\Program.cs:line 598

Improve how duplicate mods are handled.

commented

Proposed solution:

If the mods have the same UniqueID in their manifest, load the one with the highest version; otherwise load the first one. For mods not loaded, show an error like this:

Skipped Trainer Mod in Mods/TrainerMod-copy because its assembly is already loaded from Mods/TrainerMod.

commented

Would maybe an error in the console (similar to dependency problems) be better? I'm mainly thinking for if the user goes to edit a config file, and it ends up being the one that isn't loaded.

commented

Yep, the error I mentioned would be shown in the console for the duplicates. The error would mention which one was loaded.

commented

Sorry, I meant an error instead of either being loaded.

commented

Yes, I might do that. The mods themselves might be the same, but as you said they may have configured them differently.

commented

Every mod in SMAPI 2.0 must have a unique ID. After #323, SMAPI will refuse to load mods which share a unique ID. That pretty much implements this ticket too, since duplicate mods will have the same ID.