diff --git a/BoosterManager/BoosterManager.cs b/BoosterManager/BoosterManager.cs index 9c3f341..81cb008 100644 --- a/BoosterManager/BoosterManager.cs +++ b/BoosterManager/BoosterManager.cs @@ -12,8 +12,10 @@ namespace BoosterManager { [Export(typeof(IPlugin))] - public sealed class BoosterManager : IASF, IBotModules, IBotCommand2, IBotTradeOfferResults { + public sealed class BoosterManager : IASF, IBotModules, IBotCommand2, IBotTradeOfferResults, IGitHubPluginUpdates { public string Name => nameof(BoosterManager); + public string RepositoryName => "Citrinate/BoosterManager"; + public bool CanUpdate => !BoosterHandler.IsCraftingOneTimeBoosters(); public Version Version => typeof(BoosterManager).Assembly.GetName().Version ?? new Version("0"); public Task OnLoaded() { diff --git a/BoosterManager/Boosters/BoosterQueue.cs b/BoosterManager/Boosters/BoosterQueue.cs index 2d445a1..46eaeeb 100644 --- a/BoosterManager/Boosters/BoosterQueue.cs +++ b/BoosterManager/Boosters/BoosterQueue.cs @@ -330,7 +330,7 @@ internal string GetStatus() { private bool FilterBoosterByType(Booster booster, BoosterType type) => type == BoosterType.Any || booster.Type == type; private HashSet GetBoosters(BoosterType type, bool? wasCrafted = null) => Boosters.Values.Where(booster => (wasCrafted == null || booster.WasCrafted == wasCrafted) && FilterBoosterByType(booster, type)).ToHashSet(); private HashSet GetBoosterIDs(BoosterType type, bool? wasCrafted = null) => GetBoosters(type, wasCrafted).Select(booster => booster.GameID).ToHashSet(); - private int GetNumBoosters(BoosterType type, bool? wasCrafted = null) => GetBoosters(type, wasCrafted).Count; + internal int GetNumBoosters(BoosterType type, bool? wasCrafted = null) => GetBoosters(type, wasCrafted).Count; internal int GetGemsNeeded(BoosterType type, bool? wasCrafted = null) => GetBoosters(type, wasCrafted).Sum(booster => (int) booster.Info.Price); internal void ForceUpdateBoosterInfos() => OnBoosterInfosUpdated -= ForceUpdateBoosterInfos; private static int GetMillisecondsFromNow(DateTime then) => Math.Max(0, (int) (then - DateTime.Now).TotalMilliseconds); diff --git a/BoosterManager/Handlers/BoosterHandler.cs b/BoosterManager/Handlers/BoosterHandler.cs index d41e803..4dd501a 100644 --- a/BoosterManager/Handlers/BoosterHandler.cs +++ b/BoosterManager/Handlers/BoosterHandler.cs @@ -214,6 +214,10 @@ internal void StartMarketTimer(uint minutes) { ); } + internal static bool IsCraftingOneTimeBoosters() { + return BoosterHandlers.Any(handler => handler.Value.BoosterQueue.GetNumBoosters(BoosterType.OneTime, wasCrafted: false) > 0); + } + private static int GetMillisecondsFromNow(DateTime then) => Math.Max(0, (int) (then - DateTime.Now).TotalMilliseconds); } }