remove some unused/redundant code
This commit is contained in:
parent
0539bb8f37
commit
077d8e4f40
|
@ -562,7 +562,7 @@ namespace StardewModdingApi.Installer
|
|||
{
|
||||
try
|
||||
{
|
||||
FileUtilities.ForceDelete(Directory.Exists(path) ? new DirectoryInfo(path) : (FileSystemInfo)new FileInfo(path));
|
||||
FileUtilities.ForceDelete(Directory.Exists(path) ? new DirectoryInfo(path) : new FileInfo(path));
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace StardewModdingAPI.Internal
|
|||
|
||||
case ReflectionTypeLoadException ex:
|
||||
string summary = ex.ToString();
|
||||
foreach (Exception childEx in ex.LoaderExceptions ?? Array.Empty<Exception>())
|
||||
foreach (Exception childEx in ex.LoaderExceptions)
|
||||
summary += $"\n\n{childEx?.GetLogSummary()}";
|
||||
message = summary;
|
||||
break;
|
||||
|
@ -43,15 +43,6 @@ namespace StardewModdingAPI.Internal
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>Get the lowest exception in an exception stack.</summary>
|
||||
/// <param name="exception">The exception from which to search.</param>
|
||||
public static Exception GetInnermostException(this Exception exception)
|
||||
{
|
||||
while (exception.InnerException != null)
|
||||
exception = exception.InnerException;
|
||||
return exception;
|
||||
}
|
||||
|
||||
/// <summary>Simplify common patterns in exception log messages that don't convey useful info.</summary>
|
||||
/// <param name="message">The log message to simplify.</param>
|
||||
public static string SimplifyExtensionMessage(string message)
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace SMAPI.ModBuildConfig.Analyzer.Tests.Framework
|
|||
var builder = new StringBuilder();
|
||||
for (int i = 0; i < diagnostics.Length; ++i)
|
||||
{
|
||||
builder.AppendLine("// " + diagnostics[i].ToString());
|
||||
builder.AppendLine("// " + diagnostics[i]);
|
||||
|
||||
var analyzerType = analyzer.GetType();
|
||||
var rules = analyzer.SupportedDiagnostics;
|
||||
|
|
|
@ -227,10 +227,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
|
|||
|
||||
// warn: implicit conversion
|
||||
if (this.IsInvalidConversion(memberType.Type, memberType.ConvertedType))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(this.AvoidImplicitNetFieldCastRule, context.Node.GetLocation(), context.Node, memberType.Type.Name, memberType.ConvertedType));
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace StardewModdingAPI.ModBuildConfig.Analyzer
|
|||
try
|
||||
{
|
||||
// get reference info
|
||||
if (!AnalyzerUtilities.TryGetMemberInfo(context.Node, context.SemanticModel, out ITypeSymbol declaringType, out TypeInfo memberType, out string memberName))
|
||||
if (!AnalyzerUtilities.TryGetMemberInfo(context.Node, context.SemanticModel, out ITypeSymbol declaringType, out _, out string memberName))
|
||||
return;
|
||||
|
||||
// suggest replacement
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands
|
|||
List<string[]> lines = new List<string[]>(rows.Length + 2)
|
||||
{
|
||||
header,
|
||||
header.Select((value, i) => "".PadRight(widths[i], '-')).ToArray()
|
||||
header.Select((_, i) => "".PadRight(widths[i], '-')).ToArray()
|
||||
};
|
||||
lines.AddRange(rows);
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
||||
{
|
||||
/// <summary>A command which runs one of the game's save migrations.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class ApplySaveFixCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using StardewValley;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
||||
{
|
||||
/// <summary>A command which sends a debug command to the game.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class DebugCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Netcode;
|
||||
|
@ -9,6 +10,7 @@ using StardewValley.Network;
|
|||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
||||
{
|
||||
/// <summary>A command which regenerates the game's bundles.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class RegenerateBundlesCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System.Diagnostics;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
||||
{
|
||||
/// <summary>A command which shows the data files.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class ShowDataFilesCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
||||
{
|
||||
/// <summary>A command which shows the game files.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class ShowGameFilesCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
||||
{
|
||||
/// <summary>A command which logs the keys being pressed for 30 seconds once enabled.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class TestInputCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
@ -37,9 +39,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Other
|
|||
public override void OnUpdated(IMonitor monitor)
|
||||
{
|
||||
// handle expiry
|
||||
if (this.ExpiryTicks == null)
|
||||
return;
|
||||
if (this.ExpiryTicks <= DateTime.UtcNow.Ticks)
|
||||
if (this.ExpiryTicks != null && this.ExpiryTicks <= DateTime.UtcNow.Ticks)
|
||||
{
|
||||
monitor.Log("No longer logging input.", LogLevel.Info);
|
||||
this.ExpiryTicks = null;
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which list item types.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class ListItemTypesCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which list items available to spawn.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class ListItemsCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the color of a player feature.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetColorCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
@ -10,6 +11,7 @@ using StardewValley.GameData;
|
|||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which changes the player's farm type.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetFarmTypeCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's current health.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetHealthCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's current immunity.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetImmunityCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's maximum health.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetMaxHealthCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's maximum stamina.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetMaxStaminaCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's current money.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetMoneyCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's name.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetNameCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits the player's current stamina.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetStaminaCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player
|
||||
{
|
||||
/// <summary>A command which edits a player style.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetStyleCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewValley;
|
||||
using StardewValley.Locations;
|
||||
|
@ -9,6 +10,7 @@ using SObject = StardewValley.Object;
|
|||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which clears in-game objects.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class ClearCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
@ -113,7 +115,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
|||
|
||||
case "furniture":
|
||||
{
|
||||
int removed = this.RemoveFurniture(location, furniture => true);
|
||||
int removed = this.RemoveFurniture(location, _ => true);
|
||||
monitor.Log($"Done! Removed {removed} entities from {location.Name}.", LogLevel.Info);
|
||||
break;
|
||||
}
|
||||
|
@ -137,11 +139,11 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
|||
{
|
||||
bool everything = type == "everything";
|
||||
int removed =
|
||||
this.RemoveFurniture(location, p => true)
|
||||
+ this.RemoveObjects(location, p => true)
|
||||
+ this.RemoveTerrainFeatures(location, p => true)
|
||||
this.RemoveFurniture(location, _ => true)
|
||||
+ this.RemoveObjects(location, _ => true)
|
||||
+ this.RemoveTerrainFeatures(location, _ => true)
|
||||
+ this.RemoveLargeTerrainFeatures(location, p => everything || p is not Bush bush || bush.isDestroyable(location, p.currentTileLocation))
|
||||
+ this.RemoveResourceClumps(location, p => true);
|
||||
+ this.RemoveResourceClumps(location, _ => true);
|
||||
monitor.Log($"Done! Removed {removed} entities from {location.Name}.", LogLevel.Info);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
using StardewValley.Locations;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which moves the player to the next mine level.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class DownMineLevelCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which immediately warps all NPCs to their scheduled positions. To hurry a single NPC, see <c>debug hurry npc-name</c> instead.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class HurryAllCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewModdingAPI.Utilities;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which sets the current day.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetDayCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which moves the player to the given mine level.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetMineLevelCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewModdingAPI.Utilities;
|
||||
using StardewValley;
|
||||
|
@ -5,6 +6,7 @@ using StardewValley;
|
|||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which sets the current season.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetSeasonCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using StardewValley;
|
||||
|
@ -5,6 +6,7 @@ using StardewValley;
|
|||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which sets the current time.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetTimeCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using StardewModdingAPI.Utilities;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.World
|
||||
{
|
||||
/// <summary>A command which sets the current year.</summary>
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global", Justification = "Loaded using reflection")]
|
||||
internal class SetYearCommand : ConsoleCommand
|
||||
{
|
||||
/*********
|
||||
|
|
|
@ -43,16 +43,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.ItemData
|
|||
this.Item = createItem(this);
|
||||
}
|
||||
|
||||
/// <summary>Construct an instance.</summary>
|
||||
/// <param name="item">The item metadata to copy.</param>
|
||||
public SearchableItem(SearchableItem item)
|
||||
{
|
||||
this.Type = item.Type;
|
||||
this.ID = item.ID;
|
||||
this.CreateItem = item.CreateItem;
|
||||
this.Item = item.Item;
|
||||
}
|
||||
|
||||
/// <summary>Get whether the item name contains a case-insensitive substring.</summary>
|
||||
/// <param name="substring">The substring to find.</param>
|
||||
public bool NameContains(string substring)
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework
|
|||
foreach (int id in this.TryLoad<int, string>("Data\\weapons").Keys)
|
||||
{
|
||||
yield return this.TryCreate(ItemType.Weapon, id, p => p.ID is >= 32 and <= 34
|
||||
? (Item)new Slingshot(p.ID)
|
||||
? new Slingshot(p.ID)
|
||||
: new MeleeWeapon(p.ID)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches
|
|||
private static Exception Finalize_LoadFarmType(Exception __exception)
|
||||
{
|
||||
// missing custom farm type
|
||||
if (__exception?.Message?.Contains("not a valid farm type") == true && !int.TryParse(SaveGame.loaded.whichFarm, out _))
|
||||
if (__exception?.Message.Contains("not a valid farm type") == true && !int.TryParse(SaveGame.loaded.whichFarm, out _))
|
||||
{
|
||||
SaveGamePatcher.Monitor.Log(__exception.GetLogSummary(), LogLevel.Error);
|
||||
SaveGamePatcher.Monitor.Log($"Removed invalid custom farm type '{SaveGame.loaded.whichFarm}' to avoid a crash when loading save '{Constants.SaveFolderName}'. (Did you remove a custom farm type mod?)", LogLevel.Warn);
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace StardewModdingAPI.Mods.SaveBackup
|
|||
// back up & prune saves
|
||||
Task
|
||||
.Run(() => this.CreateBackup(backupFolder))
|
||||
.ContinueWith(backupTask => this.PruneBackups(backupFolder, this.BackupsToKeep));
|
||||
.ContinueWith(_ => this.PruneBackups(backupFolder, this.BackupsToKeep));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -170,8 +170,8 @@ namespace StardewModdingAPI.Mods.SaveBackup
|
|||
try
|
||||
{
|
||||
// create compressed backup
|
||||
Assembly coreAssembly = Assembly.Load("System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") ?? throw new InvalidOperationException("Can't load System.IO.Compression assembly.");
|
||||
Assembly fsAssembly = Assembly.Load("System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089") ?? throw new InvalidOperationException("Can't load System.IO.Compression assembly.");
|
||||
Assembly coreAssembly = Assembly.Load("System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
|
||||
Assembly fsAssembly = Assembly.Load("System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
|
||||
Type compressionLevelType = coreAssembly.GetType("System.IO.Compression.CompressionLevel") ?? throw new InvalidOperationException("Can't load CompressionLevel type.");
|
||||
Type zipFileType = fsAssembly.GetType("System.IO.Compression.ZipFile") ?? throw new InvalidOperationException("Can't load ZipFile type.");
|
||||
createFromDirectory = zipFileType.GetMethod("CreateFromDirectory", new[] { typeof(string), typeof(string), compressionLevelType, typeof(bool) }) ?? throw new InvalidOperationException("Can't load ZipFile.CreateFromDirectory method.");
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace SMAPI.Tests.ModApiConsumer
|
|||
// act
|
||||
int calls = 0;
|
||||
int lastValue = -1;
|
||||
api.OnEventRaised += (sender, value) =>
|
||||
api.OnEventRaised += (_, value) =>
|
||||
{
|
||||
calls++;
|
||||
lastValue = value;
|
||||
|
@ -34,7 +34,7 @@ namespace SMAPI.Tests.ModApiConsumer
|
|||
// act
|
||||
int calls = 0;
|
||||
int lastValue = -1;
|
||||
api.OnEventRaisedProperty += (sender, value) =>
|
||||
api.OnEventRaisedProperty += (_, value) =>
|
||||
{
|
||||
calls++;
|
||||
lastValue = value;
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace SMAPI.Tests.Core
|
|||
|
||||
// act
|
||||
string calledWithLocale = null;
|
||||
IAssetName assetName = AssetName.Parse(name, parseLocale: locale => expectedLanguageCode);
|
||||
IAssetName assetName = AssetName.Parse(name, parseLocale: _ => expectedLanguageCode);
|
||||
|
||||
// assert
|
||||
assetName.Name.Should()
|
||||
|
@ -161,7 +161,7 @@ namespace SMAPI.Tests.Core
|
|||
AssetName name = AssetName.Parse(mainAssetName, _ => null);
|
||||
|
||||
// assert value is the same for any combination of options
|
||||
bool result = name.StartsWith(prefix, true, true);
|
||||
bool result = name.StartsWith(prefix);
|
||||
foreach (bool allowPartialWord in new[] { true, false })
|
||||
{
|
||||
foreach (bool allowSubfolder in new[] { true, true })
|
||||
|
|
|
@ -123,7 +123,7 @@ namespace SMAPI.Tests.Core
|
|||
[Test(Description = "Assert that validation doesn't fail if there are no mods installed.")]
|
||||
public void ValidateManifests_NoMods_DoesNothing()
|
||||
{
|
||||
new ModResolver().ValidateManifests(Array.Empty<ModMetadata>(), apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(Array.Empty<ModMetadata>(), apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
}
|
||||
|
||||
[Test(Description = "Assert that validation skips manifests that have already failed without calling any other properties.")]
|
||||
|
@ -134,7 +134,7 @@ namespace SMAPI.Tests.Core
|
|||
mock.Setup(p => p.Status).Returns(ModMetadataStatus.Failed);
|
||||
|
||||
// act
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
|
||||
// assert
|
||||
mock.VerifyGet(p => p.Status, Times.Once, "The validation did not check the manifest status.");
|
||||
|
@ -151,7 +151,7 @@ namespace SMAPI.Tests.Core
|
|||
});
|
||||
|
||||
// act
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
|
||||
// assert
|
||||
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
|
||||
|
@ -166,7 +166,7 @@ namespace SMAPI.Tests.Core
|
|||
this.SetupMetadataForValidation(mock);
|
||||
|
||||
// act
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
|
||||
// assert
|
||||
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
|
||||
|
@ -180,7 +180,7 @@ namespace SMAPI.Tests.Core
|
|||
this.SetupMetadataForValidation(mock);
|
||||
|
||||
// act
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
|
||||
// assert
|
||||
mock.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the metadata.");
|
||||
|
@ -197,7 +197,7 @@ namespace SMAPI.Tests.Core
|
|||
this.SetupMetadataForValidation(mod);
|
||||
|
||||
// act
|
||||
new ModResolver().ValidateManifests(new[] { modA.Object, modB.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(new[] { modA.Object, modB.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
|
||||
// assert
|
||||
modA.Verify(p => p.SetStatus(ModMetadataStatus.Failed, It.IsAny<ModFailReason>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once, "The validation did not fail the first mod with a unique ID.");
|
||||
|
@ -223,7 +223,7 @@ namespace SMAPI.Tests.Core
|
|||
mock.Setup(p => p.DirectoryPath).Returns(modFolder);
|
||||
|
||||
// act
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: key => null);
|
||||
new ModResolver().ValidateManifests(new[] { mock.Object }, apiVersion: new SemanticVersion("1.0"), getUpdateUrl: _ => null);
|
||||
|
||||
// assert
|
||||
// if Moq doesn't throw a method-not-setup exception, the validation didn't override the status.
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using StardewModdingAPI;
|
||||
using StardewModdingAPI.Toolkit.Framework.Clients.Wiki;
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.Wiki
|
|||
|
||||
foreach (var entry in this.ParseOverrideEntries(modNodes))
|
||||
{
|
||||
if (entry.Ids?.Any() != true || !entry.HasChanges)
|
||||
if (entry.Ids.Any() != true || !entry.HasChanges)
|
||||
continue;
|
||||
|
||||
foreach (string id in entry.Ids)
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace StardewModdingAPI.Toolkit.Framework.ModData
|
|||
*********/
|
||||
/// <summary>Construct an empty instance.</summary>
|
||||
public ModDatabase()
|
||||
: this(Array.Empty<ModDataRecord>(), key => null) { }
|
||||
: this(Array.Empty<ModDataRecord>(), _ => null) { }
|
||||
|
||||
/// <summary>Construct an instance.</summary>
|
||||
/// <param name="records">The underlying mod data records indexed by default display name.</param>
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
return this.View("Index", this.GetModel(result.ID, schemaName, isEditView: true).SetContent(input, null).SetUploadError(result.UploadError));
|
||||
|
||||
// redirect to view
|
||||
return this.Redirect(this.Url.PlainAction("Index", "JsonValidator", new { schemaName = schemaName, id = result.ID }));
|
||||
return this.Redirect(this.Url.PlainAction("Index", "JsonValidator", new { schemaName, id = result.ID }));
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,13 +317,10 @@ namespace StardewModdingAPI.Web.Controllers
|
|||
/// <param name="key">The case-insensitive field key.</param>
|
||||
private T GetExtensionField<T>(JSchema schema, string key)
|
||||
{
|
||||
if (schema.ExtensionData != null)
|
||||
foreach ((string curKey, JToken value) in schema.ExtensionData)
|
||||
{
|
||||
foreach ((string curKey, JToken value) in schema.ExtensionData)
|
||||
{
|
||||
if (curKey.Equals(key, StringComparison.OrdinalIgnoreCase))
|
||||
return value.ToObject<T>();
|
||||
}
|
||||
if (curKey.Equals(key, StringComparison.OrdinalIgnoreCase))
|
||||
return value.ToObject<T>();
|
||||
}
|
||||
|
||||
return default;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using StardewModdingAPI.Toolkit.Framework.UpdateData;
|
||||
using StardewModdingAPI.Web.Framework.Clients;
|
||||
|
||||
namespace StardewModdingAPI.Web.Framework.Caching.Mods
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using StardewModdingAPI.Toolkit.Framework.UpdateData;
|
||||
using StardewModdingAPI.Web.Framework.Clients;
|
||||
|
||||
namespace StardewModdingAPI.Web.Framework.Caching.Mods
|
||||
{
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
|
|||
{
|
||||
Match match = this.ModPathPattern.Match(message.Text);
|
||||
log.ModPath = match.Groups["path"].Value;
|
||||
int lastDelimiterPos = log.ModPath.LastIndexOfAny(new char[] { '/', '\\' });
|
||||
int lastDelimiterPos = log.ModPath.LastIndexOfAny(new[] { '/', '\\' });
|
||||
log.GamePath = lastDelimiterPos >= 0
|
||||
? log.ModPath.Substring(0, lastDelimiterPos)
|
||||
: log.ModPath;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
using StardewModdingAPI.Web.Framework.Clients;
|
||||
|
||||
namespace StardewModdingAPI.Web.Framework
|
||||
{
|
||||
/// <summary>Generic metadata about a mod.</summary>
|
||||
|
|
|
@ -37,8 +37,6 @@ namespace StardewModdingAPI.Web.Framework.RedirectRules
|
|||
{
|
||||
// get requested host
|
||||
string host = context.HttpContext.Request.Host.Host;
|
||||
if (host == null)
|
||||
return null;
|
||||
|
||||
// get new host
|
||||
host = this.Map(host);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace StardewModdingAPI.Web.Framework.RedirectRules
|
|||
/// <param name="except">Matches requests which should be ignored.</param>
|
||||
public RedirectToHttpsRule(Func<HttpRequest, bool> except = null)
|
||||
{
|
||||
this.Except = except ?? (req => false);
|
||||
this.Except = except ?? (_ => false);
|
||||
this.StatusCode = HttpStatusCode.RedirectKeepVerb;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace StardewModdingAPI.Web
|
|||
|
||||
// init Hangfire
|
||||
services
|
||||
.AddHangfire((serv, config) =>
|
||||
.AddHangfire((_, config) =>
|
||||
{
|
||||
config
|
||||
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
smapi.logParser({
|
||||
logStarted: new Date(@this.ForJson(log?.Timestamp)),
|
||||
showPopup: @this.ForJson(log == null),
|
||||
showMods: @this.ForJson(log?.Mods?.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, slug => true)),
|
||||
showSections: @this.ForJson(Enum.GetNames(typeof(LogSection)).ToDictionary(section => section, section => false)),
|
||||
showMods: @this.ForJson(log?.Mods?.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, _ => true)),
|
||||
showSections: @this.ForJson(Enum.GetNames(typeof(LogSection)).ToDictionary(section => section, _ => false)),
|
||||
showLevels: @this.ForJson(defaultFilters),
|
||||
enableFilters: @this.ForJson(!Model.ShowRaw),
|
||||
screenIds: @this.ForJson(screenIds)
|
||||
|
@ -207,7 +207,7 @@ else if (log?.IsValid == true)
|
|||
@if (mod.HasUpdate)
|
||||
{
|
||||
<a href="@mod.UpdateLink" target="_blank">
|
||||
@(mod.Version == null ? @mod.UpdateVersion : $"{mod.Version} → {mod.UpdateVersion}")
|
||||
@(mod.Version == null ? mod.UpdateVersion : $"{mod.Version} → {mod.UpdateVersion}")
|
||||
</a>
|
||||
}
|
||||
else
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
border-radius: 5px;
|
||||
border: 1px solid #000088;
|
||||
outline: none;
|
||||
box-shadow: inset 0px 0px 1px 1px rgba(0, 0, 192, .2);
|
||||
box-shadow: inset 0 0 1px 1px rgba(0, 0, 192, .2);
|
||||
}
|
||||
|
||||
#submit {
|
||||
|
|
|
@ -170,9 +170,6 @@ namespace StardewModdingAPI
|
|||
/// <summary>The target game platform as a SMAPI toolkit constant.</summary>
|
||||
internal static Platform Platform { get; } = (Platform)Constants.TargetPlatform;
|
||||
|
||||
/// <summary>The language code for non-translated mod assets.</summary>
|
||||
internal static LocalizedContentManager.LanguageCode DefaultLanguage { get; } = LocalizedContentManager.LanguageCode.en;
|
||||
|
||||
|
||||
/*********
|
||||
** Internal methods
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace StardewModdingAPI.Framework
|
|||
/// <exception cref="ArgumentException">There's already a command with that name.</exception>
|
||||
public CommandManager Add(IInternalCommand command, IMonitor monitor)
|
||||
{
|
||||
return this.Add(null, command.Name, command.Description, (name, args) => command.HandleCommand(args, monitor));
|
||||
return this.Add(null, command.Name, command.Description, (_, args) => command.HandleCommand(args, monitor));
|
||||
}
|
||||
|
||||
/// <summary>Get a command by its unique name.</summary>
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace StardewModdingAPI.Framework.Content
|
|||
{
|
||||
switch (sourceTile)
|
||||
{
|
||||
case StaticTile _:
|
||||
case StaticTile:
|
||||
return new StaticTile(targetLayer, targetSheet, sourceTile.BlendMode, sourceTile.TileIndex);
|
||||
|
||||
case AnimatedTile animatedTile:
|
||||
|
|
|
@ -107,7 +107,7 @@ namespace StardewModdingAPI.Framework.Content
|
|||
return this.BaseName.Equals(assetName?.BaseName, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (assetName is AssetName impl)
|
||||
return this.ComparableName == impl?.ComparableName;
|
||||
return this.ComparableName == impl.ComparableName;
|
||||
|
||||
return this.Name.Equals(assetName?.Name, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
using System.Numerics;
|
||||
using xTile.Dimensions;
|
||||
|
||||
namespace StardewModdingAPI.Framework.Content
|
||||
|
|
|
@ -308,7 +308,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
|||
{
|
||||
return useCache
|
||||
? base.LoadBase<T>(assetName.Name)
|
||||
: base.ReadAsset<T>(assetName.Name, disposable => this.Disposables.Add(new WeakReference<IDisposable>(disposable)));
|
||||
: this.ReadAsset<T>(assetName.Name, disposable => this.Disposables.Add(new WeakReference<IDisposable>(disposable)));
|
||||
}
|
||||
|
||||
/// <summary>Add tracking data to an asset and add it to the cache.</summary>
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
|
|||
}
|
||||
|
||||
// track & return asset
|
||||
this.TrackAsset(assetName, asset, useCache);
|
||||
this.TrackAsset(assetName, asset, useCache: false);
|
||||
return asset;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ namespace StardewModdingAPI.Framework.Input
|
|||
var keyboard = new KeyboardStateBuilder(base.GetKeyboardState());
|
||||
var mouse = new MouseStateBuilder(base.GetMouseState());
|
||||
Vector2 cursorAbsolutePos = new((mouse.X * zoomMultiplier) + Game1.viewport.X, (mouse.Y * zoomMultiplier) + Game1.viewport.Y);
|
||||
Vector2? playerTilePos = Context.IsPlayerFree ? Game1.player.getTileLocation() : (Vector2?)null;
|
||||
Vector2? playerTilePos = Context.IsPlayerFree ? Game1.player.getTileLocation() : null;
|
||||
HashSet<SButton> reallyDown = new HashSet<SButton>(this.GetPressedButtons(keyboard, mouse, controller));
|
||||
|
||||
// apply overrides
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewModdingAPI.Framework.Events;
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
|
|||
// get raw API
|
||||
IModMetadata mod = this.Registry.Get(uniqueID);
|
||||
if (mod?.Api != null && this.AccessedModApis.Add(mod.Manifest.UniqueID))
|
||||
this.Monitor.Log($"Accessed mod-provided API for {mod.DisplayName}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Accessed mod-provided API for {mod.DisplayName}.");
|
||||
return mod?.Api;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace StardewModdingAPI.Framework.ModLoading
|
|||
if (changed)
|
||||
{
|
||||
if (!oneAssembly)
|
||||
this.Monitor.Log($" Loading {assembly.File.Name} (rewritten)...", LogLevel.Trace);
|
||||
this.Monitor.Log($" Loading {assembly.File.Name} (rewritten)...");
|
||||
|
||||
// load assembly
|
||||
using MemoryStream outAssemblyStream = new();
|
||||
|
@ -150,7 +150,7 @@ namespace StardewModdingAPI.Framework.ModLoading
|
|||
else
|
||||
{
|
||||
if (!oneAssembly)
|
||||
this.Monitor.Log($" Loading {assembly.File.Name}...", LogLevel.Trace);
|
||||
this.Monitor.Log($" Loading {assembly.File.Name}...");
|
||||
lastAssembly = Assembly.UnsafeLoadFrom(assembly.File.FullName);
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace StardewModdingAPI.Framework.ModLoading
|
|||
// initialize metadata
|
||||
mods = mods.ToArray();
|
||||
var sortedMods = new Stack<IModMetadata>();
|
||||
var states = mods.ToDictionary(mod => mod, mod => ModDependencyStatus.Queued);
|
||||
var states = mods.ToDictionary(mod => mod, _ => ModDependencyStatus.Queued);
|
||||
|
||||
// handle failed mods
|
||||
foreach (IModMetadata mod in mods.Where(m => m.Status == ModMetadataStatus.Failed))
|
||||
|
|
|
@ -96,8 +96,6 @@ namespace StardewModdingAPI.Framework
|
|||
// get stack frames
|
||||
StackTrace stack = new();
|
||||
StackFrame[] frames = stack.GetFrames();
|
||||
if (frames == null)
|
||||
return null;
|
||||
|
||||
// search stack for a source assembly
|
||||
foreach (StackFrame frame in frames)
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace StardewModdingAPI.Framework
|
|||
public void VerboseLog(string message)
|
||||
{
|
||||
if (this.IsVerbose)
|
||||
this.Log(message, LogLevel.Trace);
|
||||
this.Log(message);
|
||||
}
|
||||
|
||||
/// <summary>Write a newline to the console and log file.</summary>
|
||||
|
|
|
@ -232,13 +232,13 @@ namespace StardewModdingAPI.Framework
|
|||
this.Toolkit.JsonHelper.JsonSettings.Converters.Add(converter);
|
||||
|
||||
// add error handlers
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) => this.Monitor.Log($"Critical app domain exception: {e.ExceptionObject}", LogLevel.Error);
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => this.Monitor.Log($"Critical app domain exception: {e.ExceptionObject}", LogLevel.Error);
|
||||
|
||||
// add more lenient assembly resolver
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => AssemblyLoader.ResolveAssembly(e.Name);
|
||||
AppDomain.CurrentDomain.AssemblyResolve += (_, e) => AssemblyLoader.ResolveAssembly(e.Name);
|
||||
|
||||
// hook locale event
|
||||
LocalizedContentManager.OnLanguageChange += locale => this.OnLocaleChanged();
|
||||
LocalizedContentManager.OnLanguageChange += _ => this.OnLocaleChanged();
|
||||
|
||||
// override game
|
||||
this.Multiplayer = new SMultiplayer(this.Monitor, this.EventManager, this.Toolkit.JsonHelper, this.ModRegistry, this.Reflection, this.OnModMessageReceived, this.Settings.LogNetworkTraffic);
|
||||
|
@ -1453,14 +1453,12 @@ namespace StardewModdingAPI.Framework
|
|||
// check Stardew64Installer version
|
||||
if (Constants.IsPatchedByStardew64Installer(out ISemanticVersion patchedByVersion))
|
||||
{
|
||||
ISemanticVersion updateFound = null;
|
||||
string updateUrl = null;
|
||||
try
|
||||
{
|
||||
// fetch update check
|
||||
ModEntryModel response = client.GetModInfo(new[] { new ModSearchEntryModel("Steviegt6.Stardew64Installer", patchedByVersion, new[] { $"GitHub:{this.Settings.Stardew64InstallerGitHubProjectName}" }) }, apiVersion: Constants.ApiVersion, gameVersion: Constants.GameVersion, platform: Constants.Platform).Single().Value;
|
||||
updateFound = response.SuggestedUpdate?.Version;
|
||||
updateUrl = response.SuggestedUpdate?.Url ?? Constants.HomePageUrl;
|
||||
ISemanticVersion updateFound = response.SuggestedUpdate?.Version;
|
||||
string updateUrl = response.SuggestedUpdate?.Url ?? Constants.HomePageUrl;
|
||||
|
||||
// log message
|
||||
if (updateFound != null)
|
||||
|
@ -1658,8 +1656,8 @@ namespace StardewModdingAPI.Framework
|
|||
// ReSharper restore SuspiciousTypeConversion.Global
|
||||
|
||||
ContentHelper content = helper.GetLegacyContentHelper();
|
||||
content.ObservableAssetEditors.CollectionChanged += (sender, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetEditor>(), e.OldItems?.Cast<IAssetEditor>(), this.ContentCore.Editors);
|
||||
content.ObservableAssetLoaders.CollectionChanged += (sender, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetLoader>(), e.OldItems?.Cast<IAssetLoader>(), this.ContentCore.Loaders);
|
||||
content.ObservableAssetEditors.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetEditor>(), e.OldItems?.Cast<IAssetEditor>(), this.ContentCore.Editors);
|
||||
content.ObservableAssetLoaders.CollectionChanged += (_, e) => this.OnAssetInterceptorsChanged(metadata, e.NewItems?.Cast<IAssetLoader>(), e.OldItems?.Cast<IAssetLoader>(), this.ContentCore.Loaders);
|
||||
}
|
||||
|
||||
// call entry method
|
||||
|
|
|
@ -111,20 +111,20 @@ namespace StardewModdingAPI.Framework
|
|||
{
|
||||
switch (client)
|
||||
{
|
||||
case LidgrenClient _:
|
||||
case LidgrenClient:
|
||||
{
|
||||
string address = this.Reflection.GetField<string>(client, "address").GetValue();
|
||||
return new SLidgrenClient(address, this.OnClientProcessingMessage, this.OnClientSendingMessage);
|
||||
}
|
||||
|
||||
case GalaxyNetClient _:
|
||||
case GalaxyNetClient:
|
||||
{
|
||||
GalaxyID address = this.Reflection.GetField<GalaxyID>(client, "lobbyId").GetValue();
|
||||
return new SGalaxyNetClient(address, this.OnClientProcessingMessage, this.OnClientSendingMessage);
|
||||
}
|
||||
|
||||
default:
|
||||
this.Monitor.Log($"Unknown multiplayer client type: {client.GetType().AssemblyQualifiedName}", LogLevel.Trace);
|
||||
this.Monitor.Log($"Unknown multiplayer client type: {client.GetType().AssemblyQualifiedName}");
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
@ -135,20 +135,20 @@ namespace StardewModdingAPI.Framework
|
|||
{
|
||||
switch (server)
|
||||
{
|
||||
case LidgrenServer _:
|
||||
case LidgrenServer:
|
||||
{
|
||||
IGameServer gameServer = this.Reflection.GetField<IGameServer>(server, "gameServer").GetValue();
|
||||
return new SLidgrenServer(gameServer, this, this.OnServerProcessingMessage);
|
||||
}
|
||||
|
||||
case GalaxyNetServer _:
|
||||
case GalaxyNetServer:
|
||||
{
|
||||
IGameServer gameServer = this.Reflection.GetField<IGameServer>(server, "gameServer").GetValue();
|
||||
return new SGalaxyNetServer(gameServer, this, this.OnServerProcessingMessage);
|
||||
}
|
||||
|
||||
default:
|
||||
this.Monitor.Log($"Unknown multiplayer server type: {server.GetType().AssemblyQualifiedName}", LogLevel.Trace);
|
||||
this.Monitor.Log($"Unknown multiplayer server type: {server.GetType().AssemblyQualifiedName}");
|
||||
return server;
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ namespace StardewModdingAPI.Framework
|
|||
protected void OnClientSendingMessage(OutgoingMessage message, Action<OutgoingMessage> sendMessage, Action resume)
|
||||
{
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"CLIENT SEND {(MessageType)message.MessageType} {message.FarmerID}", LogLevel.Trace);
|
||||
this.Monitor.Log($"CLIENT SEND {(MessageType)message.MessageType} {message.FarmerID}");
|
||||
|
||||
switch (message.MessageType)
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ namespace StardewModdingAPI.Framework
|
|||
public void OnServerProcessingMessage(IncomingMessage message, Action<OutgoingMessage> sendMessage, Action resume)
|
||||
{
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"SERVER RECV {(MessageType)message.MessageType} {message.FarmerID}", LogLevel.Trace);
|
||||
this.Monitor.Log($"SERVER RECV {(MessageType)message.MessageType} {message.FarmerID}");
|
||||
|
||||
switch (message.MessageType)
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ namespace StardewModdingAPI.Framework
|
|||
{
|
||||
// parse message
|
||||
RemoteContextModel model = this.ReadContext(message.Reader);
|
||||
this.Monitor.Log($"Received context for farmhand {message.FarmerID} running {(model != null ? $"SMAPI {model.ApiVersion} with {model.Mods.Length} mods" : "vanilla")}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Received context for farmhand {message.FarmerID} running {(model != null ? $"SMAPI {model.ApiVersion} with {model.Mods.Length} mods" : "vanilla")}.");
|
||||
|
||||
// store peer
|
||||
MultiplayerPeer newPeer = new(
|
||||
|
@ -243,7 +243,7 @@ namespace StardewModdingAPI.Framework
|
|||
// store peer if new
|
||||
if (!this.Peers.ContainsKey(message.FarmerID))
|
||||
{
|
||||
this.Monitor.Log($"Received connection for vanilla player {message.FarmerID}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Received connection for vanilla player {message.FarmerID}.");
|
||||
MultiplayerPeer peer = new(
|
||||
playerID: message.FarmerID,
|
||||
screenID: this.GetScreenId(message.FarmerID),
|
||||
|
@ -280,7 +280,7 @@ namespace StardewModdingAPI.Framework
|
|||
public void OnClientProcessingMessage(IncomingMessage message, Action<OutgoingMessage> sendMessage, Action resume)
|
||||
{
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"CLIENT RECV {(MessageType)message.MessageType} {message.FarmerID}", LogLevel.Trace);
|
||||
this.Monitor.Log($"CLIENT RECV {(MessageType)message.MessageType} {message.FarmerID}");
|
||||
|
||||
switch (message.MessageType)
|
||||
{
|
||||
|
@ -289,7 +289,7 @@ namespace StardewModdingAPI.Framework
|
|||
{
|
||||
// parse message
|
||||
RemoteContextModel model = this.ReadContext(message.Reader);
|
||||
this.Monitor.Log($"Received context for {(model?.IsHost == true ? "host" : "farmhand")} {message.FarmerID} running {(model != null ? $"SMAPI {model.ApiVersion} with {model.Mods.Length} mods" : "vanilla")}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Received context for {(model?.IsHost == true ? "host" : "farmhand")} {message.FarmerID} running {(model != null ? $"SMAPI {model.ApiVersion} with {model.Mods.Length} mods" : "vanilla")}.");
|
||||
|
||||
// store peer
|
||||
MultiplayerPeer peer = new(
|
||||
|
@ -314,7 +314,7 @@ namespace StardewModdingAPI.Framework
|
|||
// store peer
|
||||
if (!this.Peers.ContainsKey(message.FarmerID) && this.HostPeer == null)
|
||||
{
|
||||
this.Monitor.Log($"Received connection for vanilla host {message.FarmerID}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Received connection for vanilla host {message.FarmerID}.");
|
||||
var peer = new MultiplayerPeer(
|
||||
playerID: message.FarmerID,
|
||||
screenID: this.GetScreenId(message.FarmerID),
|
||||
|
@ -341,7 +341,7 @@ namespace StardewModdingAPI.Framework
|
|||
sendMessage: sendMessage,
|
||||
isHost: this.HostPeer == null
|
||||
);
|
||||
this.Monitor.Log($"Received connection for vanilla {(peer.IsHost ? "host" : "farmhand")} {message.FarmerID}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Received connection for vanilla {(peer.IsHost ? "host" : "farmhand")} {message.FarmerID}.");
|
||||
this.AddPeer(peer, canBeHost: true);
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ namespace StardewModdingAPI.Framework
|
|||
{
|
||||
if (this.Peers.TryGetValue(playerID, out MultiplayerPeer peer))
|
||||
{
|
||||
this.Monitor.Log($"Player quit: {playerID}", LogLevel.Trace);
|
||||
this.Monitor.Log($"Player quit: {playerID}");
|
||||
this.Peers.Remove(playerID);
|
||||
this.EventManager.PeerDisconnected.Raise(new PeerDisconnectedEventArgs(peer));
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ namespace StardewModdingAPI.Framework
|
|||
if (sendToSelf)
|
||||
{
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"Broadcasting '{messageType}' message to self: {data}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Broadcasting '{messageType}' message to self: {data}.");
|
||||
|
||||
this.OnModMessageReceived(model);
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ namespace StardewModdingAPI.Framework
|
|||
foreach (MultiplayerPeer peer in sendToPeers)
|
||||
{
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"Broadcasting '{messageType}' message to farmhand {peer.PlayerID}: {data}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Broadcasting '{messageType}' message to farmhand {peer.PlayerID}: {data}.");
|
||||
|
||||
peer.SendMessage(new OutgoingMessage((byte)MessageType.ModMessage, peer.PlayerID, data));
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ namespace StardewModdingAPI.Framework
|
|||
else if (this.HostPeer?.HasSmapi == true)
|
||||
{
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"Broadcasting '{messageType}' message to host {this.HostPeer.PlayerID}: {data}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Broadcasting '{messageType}' message to host {this.HostPeer.PlayerID}: {data}.");
|
||||
|
||||
this.HostPeer.SendMessage(new OutgoingMessage((byte)MessageType.ModMessage, this.HostPeer.PlayerID, data));
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ namespace StardewModdingAPI.Framework
|
|||
ModMessageModel model = this.JsonHelper.Deserialize<ModMessageModel>(json);
|
||||
HashSet<long> playerIDs = new HashSet<long>(model.ToPlayerIDs ?? this.GetKnownPlayerIDs());
|
||||
if (this.LogNetworkTraffic)
|
||||
this.Monitor.Log($"Received message: {json}.", LogLevel.Trace);
|
||||
this.Monitor.Log($"Received message: {json}.");
|
||||
|
||||
// notify local mods
|
||||
if (playerIDs.Contains(Game1.player.UniqueMultiplayerID))
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace StardewModdingAPI.Framework.Serialization
|
|||
{
|
||||
case JsonToken.Null:
|
||||
return objectType == typeof(Keybind)
|
||||
? (object)new Keybind()
|
||||
? new Keybind()
|
||||
: new KeybindList();
|
||||
|
||||
case JsonToken.String:
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace StardewModdingAPI.Framework.StateTracking.Snapshots
|
|||
Enum
|
||||
.GetValues(typeof(SkillType))
|
||||
.Cast<SkillType>()
|
||||
.ToDictionary(skill => skill, skill => new SnapshotDiff<int>());
|
||||
.ToDictionary(skill => skill, _ => new SnapshotDiff<int>());
|
||||
|
||||
/// <summary>Get a list of inventory changes.</summary>
|
||||
public SnapshotItemListDiff Inventory { get; private set; }
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace MonoMod.Utils
|
|||
}
|
||||
|
||||
public static Type GetRealDeclaringType(this MemberInfo member)
|
||||
=> member.DeclaringType ?? member.Module?.GetModuleType();
|
||||
=> member.DeclaringType ?? member.Module.GetModuleType();
|
||||
|
||||
public static void FixReflectionCache(this Type type)
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace StardewModdingAPI
|
|||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
// ignore invalid DLL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace StardewModdingAPI
|
|||
{
|
||||
foreach (DictionaryEntry entry in inputLookup)
|
||||
{
|
||||
string key = entry.Key?.ToString().Trim();
|
||||
string key = entry.Key.ToString()?.Trim();
|
||||
if (key != null)
|
||||
tokenLookup[key] = entry.Value?.ToString();
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace StardewModdingAPI.Utilities
|
|||
/// <summary>Remove all active values.</summary>
|
||||
public void ResetAllScreens()
|
||||
{
|
||||
this.RemoveScreens(p => true);
|
||||
this.RemoveScreens(_ => true);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue