diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 24c3ef8f0..764454faa 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -92,14 +92,14 @@ namespace ArchiSteamFarm { } internal static async Task Init() { - WebBrowser = new WebBrowser(ArchiLogger, GlobalConfig.WebProxy, true); - - await UpdateAndRestart().ConfigureAwait(false); - if (!PluginsCore.InitPlugins()) { await Task.Delay(10000).ConfigureAwait(false); } + WebBrowser = new WebBrowser(ArchiLogger, GlobalConfig.WebProxy, true); + + await UpdateAndRestart().ConfigureAwait(false); + await PluginsCore.OnASFInitModules(GlobalConfig.AdditionalProperties).ConfigureAwait(false); StringComparer botsComparer = await PluginsCore.GetBotsComparer().ConfigureAwait(false); diff --git a/ArchiSteamFarm/Plugins/PluginsCore.cs b/ArchiSteamFarm/Plugins/PluginsCore.cs index 1b9b9a43c..6676250d6 100644 --- a/ArchiSteamFarm/Plugins/PluginsCore.cs +++ b/ArchiSteamFarm/Plugins/PluginsCore.cs @@ -37,6 +37,8 @@ using SteamKit2; namespace ArchiSteamFarm.Plugins { internal static class PluginsCore { + internal static bool HasActivePluginsLoaded => ActivePlugins?.Count > 0; + [ImportMany] private static ImmutableHashSet ActivePlugins { get; set; } @@ -47,7 +49,7 @@ namespace ArchiSteamFarm.Plugins { return false; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return true; } @@ -66,7 +68,7 @@ namespace ArchiSteamFarm.Plugins { [ItemNotNull] internal static async Task GetBotsComparer() { - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return StringComparer.Ordinal; } @@ -86,7 +88,7 @@ namespace ArchiSteamFarm.Plugins { } internal static bool InitPlugins() { - if ((ActivePlugins != null) && (ActivePlugins.Count > 0)) { + if (HasActivePluginsLoaded) { return false; } @@ -147,6 +149,8 @@ namespace ArchiSteamFarm.Plugins { ActivePlugins = activePlugins.ToImmutableHashSet(); ASF.ArchiLogger.LogGenericInfo(Strings.PluginsWarning); + Console.Title = SharedInfo.ProgramIdentifier; + return invalidPlugins.Count == 0; } @@ -181,7 +185,7 @@ namespace ArchiSteamFarm.Plugins { } internal static async Task OnASFInitModules(IReadOnlyDictionary additionalConfigProperties = null) { - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -200,7 +204,7 @@ namespace ArchiSteamFarm.Plugins { return null; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return null; } @@ -224,7 +228,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -242,7 +246,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -260,7 +264,7 @@ namespace ArchiSteamFarm.Plugins { return false; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return false; } @@ -284,7 +288,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -302,7 +306,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -320,7 +324,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -339,7 +343,7 @@ namespace ArchiSteamFarm.Plugins { return null; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return null; } @@ -363,7 +367,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } @@ -381,7 +385,7 @@ namespace ArchiSteamFarm.Plugins { return null; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return null; } @@ -405,7 +409,7 @@ namespace ArchiSteamFarm.Plugins { return false; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return false; } @@ -429,7 +433,7 @@ namespace ArchiSteamFarm.Plugins { return; } - if ((ActivePlugins == null) || (ActivePlugins.Count == 0)) { + if (!HasActivePluginsLoaded) { return; } diff --git a/ArchiSteamFarm/Program.cs b/ArchiSteamFarm/Program.cs index 76a05aed5..17714166a 100644 --- a/ArchiSteamFarm/Program.cs +++ b/ArchiSteamFarm/Program.cs @@ -27,7 +27,6 @@ using System.Globalization; using System.IO; using System.Linq; using System.Resources; -using System.Text; using System.Threading.Tasks; using ArchiSteamFarm.IPC; using ArchiSteamFarm.Localization; @@ -131,10 +130,8 @@ namespace ArchiSteamFarm { private static async Task InitASF(IReadOnlyCollection args) { OS.CoreInit(); - string programIdentifier = SharedInfo.PublicIdentifier + " V" + SharedInfo.Version + " (" + SharedInfo.BuildInfo.Variant + "/" + SharedInfo.ModuleVersion + " | " + OS.Variant + ")"; - - Console.Title = programIdentifier; - ASF.ArchiLogger.LogGenericInfo(programIdentifier); + Console.Title = SharedInfo.ProgramIdentifier; + ASF.ArchiLogger.LogGenericInfo(SharedInfo.ProgramIdentifier); await InitGlobalConfigAndLanguage().ConfigureAwait(false); diff --git a/ArchiSteamFarm/SharedInfo.cs b/ArchiSteamFarm/SharedInfo.cs index cd93f7c7a..ee4c1c5b1 100644 --- a/ArchiSteamFarm/SharedInfo.cs +++ b/ArchiSteamFarm/SharedInfo.cs @@ -23,6 +23,7 @@ using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; +using ArchiSteamFarm.Plugins; using JetBrains.Annotations; namespace ArchiSteamFarm { @@ -57,14 +58,18 @@ namespace ArchiSteamFarm { internal const string WebsiteDirectory = "www"; internal static string HomeDirectory => Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location ?? throw new ArgumentNullException(nameof(HomeDirectory))); - internal static Guid ModuleVersion => Assembly.GetEntryAssembly()?.ManifestModule.ModuleVersionId ?? throw new ArgumentNullException(nameof(ModuleVersion)); [NotNull] - internal static string PublicIdentifier => AssemblyName + (BuildInfo.IsCustomBuild ? "-custom" : ""); + internal static string ProgramIdentifier => PublicIdentifier + " V" + Version + " (" + BuildInfo.Variant + "/" + ModuleVersion + " | " + OS.Variant + ")"; + + [NotNull] + internal static string PublicIdentifier => AssemblyName + (BuildInfo.IsCustomBuild ? "-custom" : PluginsCore.HasActivePluginsLoaded ? "-modded" : ""); [NotNull] internal static Version Version => Assembly.GetEntryAssembly()?.GetName().Version ?? throw new ArgumentNullException(nameof(Version)); + private static Guid ModuleVersion => Assembly.GetEntryAssembly()?.ManifestModule.ModuleVersionId ?? throw new ArgumentNullException(nameof(ModuleVersion)); + [SuppressMessage("ReSharper", "ConvertToConstant.Global")] internal static class BuildInfo { #if ASF_VARIANT_DOCKER