Use modded identifier for plugins setups

This commit is contained in:
JustArchi
2019-06-25 12:26:55 +02:00
parent 73a991afa8
commit 448482e499
4 changed files with 33 additions and 27 deletions

View File

@@ -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);

View File

@@ -37,6 +37,8 @@ using SteamKit2;
namespace ArchiSteamFarm.Plugins {
internal static class PluginsCore {
internal static bool HasActivePluginsLoaded => ActivePlugins?.Count > 0;
[ImportMany]
private static ImmutableHashSet<IPlugin> 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<StringComparer> 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<string, JToken> 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;
}

View File

@@ -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<string> 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);

View File

@@ -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