Allow plugins to initialize new configs with some changed properties

This commit is contained in:
Łukasz Domeradzki
2025-07-03 13:12:10 +02:00
parent e3c1a8c5fb
commit 5dadbe9090
2 changed files with 62 additions and 62 deletions

View File

@@ -196,72 +196,72 @@ public sealed class BotConfig {
}
[JsonInclude]
public bool AcceptGifts { get; private init; } = DefaultAcceptGifts;
public bool AcceptGifts { get; init; } = DefaultAcceptGifts;
[JsonInclude]
public EBotBehaviour BotBehaviour { get; private init; } = DefaultBotBehaviour;
public EBotBehaviour BotBehaviour { get; init; } = DefaultBotBehaviour;
[JsonDisallowNull]
[JsonInclude]
[SwaggerValidValues(ValidIntValues = [(int) EAssetType.FoilTradingCard, (int) EAssetType.TradingCard])]
public ImmutableHashSet<EAssetType> CompleteTypesToSend { get; private init; } = DefaultCompleteTypesToSend;
public ImmutableHashSet<EAssetType> CompleteTypesToSend { get; init; } = DefaultCompleteTypesToSend;
[JsonInclude]
public string? CustomGamePlayedWhileFarming { get; private init; } = DefaultCustomGamePlayedWhileFarming;
public string? CustomGamePlayedWhileFarming { get; init; } = DefaultCustomGamePlayedWhileFarming;
[JsonInclude]
public string? CustomGamePlayedWhileIdle { get; private init; } = DefaultCustomGamePlayedWhileIdle;
public string? CustomGamePlayedWhileIdle { get; init; } = DefaultCustomGamePlayedWhileIdle;
[JsonInclude]
public bool Enabled { get; private init; } = DefaultEnabled;
public bool Enabled { get; init; } = DefaultEnabled;
[JsonDisallowNull]
[JsonInclude]
public ImmutableList<EFarmingOrder> FarmingOrders { get; private init; } = DefaultFarmingOrders;
public ImmutableList<EFarmingOrder> FarmingOrders { get; init; } = DefaultFarmingOrders;
[JsonInclude]
public EFarmingPreferences FarmingPreferences { get; private init; } = DefaultFarmingPreferences;
public EFarmingPreferences FarmingPreferences { get; init; } = DefaultFarmingPreferences;
[JsonDisallowNull]
[JsonInclude]
[MaxLength(ArchiHandler.MaxGamesPlayedConcurrently)]
[SwaggerItemsMinMax(MinimumUint = 1, MaximumUint = uint.MaxValue)]
[UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "This is optional, supportive attribute, we don't care if it gets trimmed or not")]
public ImmutableList<uint> GamesPlayedWhileIdle { get; private init; } = DefaultGamesPlayedWhileIdle;
public ImmutableList<uint> GamesPlayedWhileIdle { get; init; } = DefaultGamesPlayedWhileIdle;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte HoursUntilCardDrops { get; private init; } = DefaultHoursUntilCardDrops;
public byte HoursUntilCardDrops { get; init; } = DefaultHoursUntilCardDrops;
[JsonDisallowNull]
[JsonInclude]
public ImmutableHashSet<EAssetType> LootableTypes { get; private init; } = DefaultLootableTypes;
public ImmutableHashSet<EAssetType> LootableTypes { get; init; } = DefaultLootableTypes;
[JsonDisallowNull]
[JsonInclude]
public ImmutableHashSet<EAssetType> MatchableTypes { get; private init; } = DefaultMatchableTypes;
public ImmutableHashSet<EAssetType> MatchableTypes { get; init; } = DefaultMatchableTypes;
[JsonInclude]
public EPersonaStateFlag OnlineFlags { get; private init; } = DefaultOnlineFlags;
public EPersonaStateFlag OnlineFlags { get; init; } = DefaultOnlineFlags;
[JsonInclude]
public EOnlinePreferences OnlinePreferences { get; private init; } = DefaultOnlinePreferences;
public EOnlinePreferences OnlinePreferences { get; init; } = DefaultOnlinePreferences;
[JsonInclude]
public EPersonaState OnlineStatus { get; private init; } = DefaultOnlineStatus;
public EPersonaState OnlineStatus { get; init; } = DefaultOnlineStatus;
[JsonInclude]
public ArchiCryptoHelper.ECryptoMethod PasswordFormat { get; internal set; } = DefaultPasswordFormat;
[JsonInclude]
public ERedeemingPreferences RedeemingPreferences { get; private init; } = DefaultRedeemingPreferences;
public ERedeemingPreferences RedeemingPreferences { get; init; } = DefaultRedeemingPreferences;
[JsonInclude]
public ERemoteCommunication RemoteCommunication { get; private init; } = DefaultRemoteCommunication;
public ERemoteCommunication RemoteCommunication { get; init; } = DefaultRemoteCommunication;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte SendTradePeriod { get; private init; } = DefaultSendTradePeriod;
public byte SendTradePeriod { get; init; } = DefaultSendTradePeriod;
[JsonInclude]
public string? SteamLogin {
@@ -276,7 +276,7 @@ public sealed class BotConfig {
[JsonInclude]
[SwaggerSteamIdentifier(AccountType = EAccountType.Clan)]
[SwaggerValidValues(ValidIntValues = [0])]
public ulong SteamMasterClanID { get; private init; } = DefaultSteamMasterClanID;
public ulong SteamMasterClanID { get; init; } = DefaultSteamMasterClanID;
[JsonInclude]
[MaxLength(SteamParentalCodeLength)]
@@ -307,35 +307,35 @@ public sealed class BotConfig {
[MaxLength(SteamTradeTokenLength)]
[MinLength(SteamTradeTokenLength)]
[UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "This is optional, supportive attribute, we don't care if it gets trimmed or not")]
public string? SteamTradeToken { get; private init; } = DefaultSteamTradeToken;
public string? SteamTradeToken { get; init; } = DefaultSteamTradeToken;
[JsonDisallowNull]
[JsonInclude]
public ImmutableDictionary<ulong, EAccess> SteamUserPermissions { get; private init; } = DefaultSteamUserPermissions;
public ImmutableDictionary<ulong, EAccess> SteamUserPermissions { get; init; } = DefaultSteamUserPermissions;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte TradeCheckPeriod { get; private init; } = DefaultTradeCheckPeriod;
public byte TradeCheckPeriod { get; init; } = DefaultTradeCheckPeriod;
[JsonInclude]
public ETradingPreferences TradingPreferences { get; private init; } = DefaultTradingPreferences;
public ETradingPreferences TradingPreferences { get; init; } = DefaultTradingPreferences;
[JsonDisallowNull]
[JsonInclude]
public ImmutableHashSet<EAssetType> TransferableTypes { get; private init; } = DefaultTransferableTypes;
public ImmutableHashSet<EAssetType> TransferableTypes { get; init; } = DefaultTransferableTypes;
[JsonInclude]
public bool UseLoginKeys { get; private init; } = DefaultUseLoginKeys;
public bool UseLoginKeys { get; init; } = DefaultUseLoginKeys;
[JsonInclude]
public EUIMode UserInterfaceMode { get; private init; } = DefaultUserInterfaceMode;
public EUIMode UserInterfaceMode { get; init; } = DefaultUserInterfaceMode;
[JsonInclude]
[JsonPropertyName(nameof(WebProxy))]
public string? WebProxyText { get; private init; } = DefaultWebProxyText;
public string? WebProxyText { get; init; } = DefaultWebProxyText;
[JsonInclude]
public string? WebProxyUsername { get; private init; } = DefaultWebProxyUsername;
public string? WebProxyUsername { get; init; } = DefaultWebProxyUsername;
[JsonExtensionData]
[JsonInclude]
@@ -374,7 +374,7 @@ public sealed class BotConfig {
}
[JsonConstructor]
internal BotConfig() { }
public BotConfig() { }
[UsedImplicitly]
public bool ShouldSerializeAcceptGifts() => !Saving || (AcceptGifts != DefaultAcceptGifts);

View File

@@ -196,57 +196,57 @@ public sealed class GlobalConfig {
}
[JsonInclude]
public bool AutoRestart { get; private init; } = DefaultAutoRestart;
public bool AutoRestart { get; init; } = DefaultAutoRestart;
[JsonDisallowNull]
[JsonInclude]
[SwaggerItemsMinMax(MinimumUint = 1, MaximumUint = uint.MaxValue)]
public ImmutableHashSet<uint> Blacklist { get; private init; } = DefaultBlacklist;
public ImmutableHashSet<uint> Blacklist { get; init; } = DefaultBlacklist;
[JsonInclude]
public string? CommandPrefix { get; private init; } = DefaultCommandPrefix;
public string? CommandPrefix { get; init; } = DefaultCommandPrefix;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte ConfirmationsLimiterDelay { get; private init; } = DefaultConfirmationsLimiterDelay;
public byte ConfirmationsLimiterDelay { get; init; } = DefaultConfirmationsLimiterDelay;
[JsonInclude]
[Range(1, byte.MaxValue)]
public byte ConnectionTimeout { get; private init; } = DefaultConnectionTimeout;
public byte ConnectionTimeout { get; init; } = DefaultConnectionTimeout;
[JsonInclude]
public string? CurrentCulture { get; private init; } = DefaultCurrentCulture;
public string? CurrentCulture { get; init; } = DefaultCurrentCulture;
[JsonInclude]
public bool Debug { get; private init; } = DefaultDebug;
public bool Debug { get; init; } = DefaultDebug;
[JsonInclude]
public string? DefaultBot { get; private init; } = DefaultDefaultBot;
public string? DefaultBot { get; init; } = DefaultDefaultBot;
[JsonInclude]
[Range(1, byte.MaxValue)]
public byte FarmingDelay { get; private init; } = DefaultFarmingDelay;
public byte FarmingDelay { get; init; } = DefaultFarmingDelay;
[JsonInclude]
public bool FilterBadBots { get; private init; } = DefaultFilterBadBots;
public bool FilterBadBots { get; init; } = DefaultFilterBadBots;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte GiftsLimiterDelay { get; private init; } = DefaultGiftsLimiterDelay;
public byte GiftsLimiterDelay { get; init; } = DefaultGiftsLimiterDelay;
[JsonInclude]
public bool Headless { get; private init; } = DefaultHeadless;
public bool Headless { get; init; } = DefaultHeadless;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte IdleFarmingPeriod { get; private init; } = DefaultIdleFarmingPeriod;
public byte IdleFarmingPeriod { get; init; } = DefaultIdleFarmingPeriod;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte InventoryLimiterDelay { get; private init; } = DefaultInventoryLimiterDelay;
public byte InventoryLimiterDelay { get; init; } = DefaultInventoryLimiterDelay;
[JsonInclude]
public bool IPC { get; private init; } = DefaultIPC;
public bool IPC { get; init; } = DefaultIPC;
[JsonInclude]
[SwaggerSecurityCritical]
@@ -260,7 +260,7 @@ public sealed class GlobalConfig {
} = DefaultIPCPassword;
[JsonInclude]
public ArchiCryptoHelper.EHashingMethod IPCPasswordFormat { get; private init; } = DefaultIPCPasswordFormat;
public ArchiCryptoHelper.EHashingMethod IPCPasswordFormat { get; init; } = DefaultIPCPasswordFormat;
[JsonConverter(typeof(GuidJsonConverter))]
[JsonInclude]
@@ -276,63 +276,63 @@ public sealed class GlobalConfig {
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte LoginLimiterDelay { get; private init; } = DefaultLoginLimiterDelay;
public byte LoginLimiterDelay { get; init; } = DefaultLoginLimiterDelay;
[JsonInclude]
[Range(1, byte.MaxValue)]
public byte MaxFarmingTime { get; private init; } = DefaultMaxFarmingTime;
public byte MaxFarmingTime { get; init; } = DefaultMaxFarmingTime;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte MaxTradeHoldDuration { get; private init; } = DefaultMaxTradeHoldDuration;
public byte MaxTradeHoldDuration { get; init; } = DefaultMaxTradeHoldDuration;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte MinFarmingDelayAfterBlock { get; private init; } = DefaultMinFarmingDelayAfterBlock;
public byte MinFarmingDelayAfterBlock { get; init; } = DefaultMinFarmingDelayAfterBlock;
[JsonInclude]
public EOptimizationMode OptimizationMode { get; private init; } = DefaultOptimizationMode;
public EOptimizationMode OptimizationMode { get; init; } = DefaultOptimizationMode;
[JsonDisallowNull]
[JsonInclude]
public ImmutableHashSet<string> PluginsUpdateList { get; private init; } = DefaultPluginsUpdateList;
public ImmutableHashSet<string> PluginsUpdateList { get; init; } = DefaultPluginsUpdateList;
[JsonInclude]
public EPluginsUpdateMode PluginsUpdateMode { get; private init; } = DefaultPluginsUpdateMode;
public EPluginsUpdateMode PluginsUpdateMode { get; init; } = DefaultPluginsUpdateMode;
[JsonInclude]
public bool ShutdownIfPossible { get; private init; } = DefaultShutdownIfPossible;
public bool ShutdownIfPossible { get; init; } = DefaultShutdownIfPossible;
[JsonInclude]
[MaxLength(SteamChatMessage.MaxMessagePrefixBytes / SteamChatMessage.ReservedEscapeMessageBytes)]
[UnconditionalSuppressMessage("AssemblyLoadTrimming", "IL2026:RequiresUnreferencedCode", Justification = "This is optional, supportive attribute, we don't care if it gets trimmed or not")]
public string? SteamMessagePrefix { get; private init; } = DefaultSteamMessagePrefix;
public string? SteamMessagePrefix { get; init; } = DefaultSteamMessagePrefix;
[JsonInclude]
[SwaggerSteamIdentifier]
[SwaggerValidValues(ValidIntValues = [0])]
public ulong SteamOwnerID { get; private init; } = DefaultSteamOwnerID;
public ulong SteamOwnerID { get; init; } = DefaultSteamOwnerID;
[JsonInclude]
public ProtocolTypes SteamProtocols { get; private init; } = DefaultSteamProtocols;
public ProtocolTypes SteamProtocols { get; init; } = DefaultSteamProtocols;
[JsonInclude]
public EUpdateChannel UpdateChannel { get; private init; } = DefaultUpdateChannel;
public EUpdateChannel UpdateChannel { get; init; } = DefaultUpdateChannel;
[JsonInclude]
[Range(byte.MinValue, byte.MaxValue)]
public byte UpdatePeriod { get; private init; } = DefaultUpdatePeriod;
public byte UpdatePeriod { get; init; } = DefaultUpdatePeriod;
[JsonInclude]
[Range(ushort.MinValue, ushort.MaxValue)]
public ushort WebLimiterDelay { get; private init; } = DefaultWebLimiterDelay;
public ushort WebLimiterDelay { get; init; } = DefaultWebLimiterDelay;
[JsonInclude]
[JsonPropertyName(nameof(WebProxy))]
public string? WebProxyText { get; private init; } = DefaultWebProxyText;
public string? WebProxyText { get; init; } = DefaultWebProxyText;
[JsonInclude]
public string? WebProxyUsername { get; private init; } = DefaultWebProxyUsername;
public string? WebProxyUsername { get; init; } = DefaultWebProxyUsername;
[JsonExtensionData]
[JsonInclude]
@@ -370,7 +370,7 @@ public sealed class GlobalConfig {
}
[JsonConstructor]
internal GlobalConfig() { }
public GlobalConfig() { }
[UsedImplicitly]
public bool ShouldSerializeAutoRestart() => !Saving || (AutoRestart != DefaultAutoRestart);