public void StopCooldown(ICooldownKey key) { if (cooldownMap.ContainsKey(key)) { cooldownMap.Remove(key); } }
private bool CheckConformation(ICooldownKey cooldownKey, long playerId, string gridName, IMyCharacter character, long ID = 0) { var cooldownManager = Plugin.ConfirmationCooldownManager; if (!cooldownManager.CheckCooldown(cooldownKey, gridName, out _)) { cooldownManager.StopCooldown(cooldownKey); return(true); } List <MyCubeGrid> GridGroups; CheckResult SearchResult; if (character == null && ID != 0) { GridGroups = ShipFixerCore.FindGridGroupsForPlayer(gridName, playerId, out SearchResult, ID); } else { if (character == null) { GridGroups = ShipFixerCore.FindGridGroupsForPlayer(gridName, playerId, out SearchResult); } else { GridGroups = ShipFixerCore.FindLookAtGridGroup(character, playerId, out SearchResult); } } if (GridGroups == null || GridGroups.Count == 0 || SearchResult != CheckResult.OK) { WriteResponse(SearchResult); return(false); } var EjectPlayers = false; CheckResult result = ShipFixerCore.CheckGroups(GridGroups, out _, playerId, EjectPlayers); if (result != CheckResult.OK) { WriteResponse(result); return(false); } cooldownManager.StartCooldown(cooldownKey, gridName, Plugin.CooldownConfirmation); Context.Respond("Are you sure you want to continue? Enter the command again within " + Plugin.CooldownConfirmationSeconds + " seconds to confirm fixship on " + GridGroups[0].DisplayName + "."); return(false); }
public void StartCooldown(ICooldownKey key, string command, long cooldown) { var currentCooldown = new CurrentCooldown(cooldown); if (cooldownMap.ContainsKey(key)) { cooldownMap[key] = currentCooldown; } else { cooldownMap.Add(key, currentCooldown); } currentCooldown.StartCooldown(command); }
public bool CheckCooldown(ICooldownKey key, string command, out long remainingSeconds) { remainingSeconds = 0; if (cooldownMap.TryGetValue(key, out CurrentCooldown currentCooldown)) { remainingSeconds = currentCooldown.GetRemainingSeconds(command); if (remainingSeconds > 0) { return(false); } } return(true); }
private bool CheckConformation(ICooldownKey cooldownKey, long playerId, string gridName, IMyCharacter character) { var cooldownManager = Plugin.ConfirmationCooldownManager; if (!cooldownManager.CheckCooldown(cooldownKey, gridName, out _)) { cooldownManager.StopCooldown(cooldownKey); return(true); } if (!CheckGridFound(playerId, gridName, character)) { return(false); } Context.Respond("Are you sure you want to continue? Enter the command again within " + Plugin.CooldownConfirmationSeconds + " seconds to confirm fixship on " + gridName + "."); cooldownManager.StartCooldown(cooldownKey, gridName, Plugin.Cooldown); return(false); }
private bool CheckConformation(ICooldownKey cooldownKey, PurchaseMode mode, long price) { var cooldownManager = Plugin.ConfirmationManager; var commandKey = mode.ToString() + price; if (!cooldownManager.CheckCooldown(cooldownKey, commandKey, out _)) { cooldownManager.StopCooldown(cooldownKey); return(true); } Context.Respond("Are you sure you want to buy a gps for '" + mode + "' for " + price.ToString("#,##0") + " SC? Make sure you read the information in !gps help. Enter the command again within 30 seconds to confirm!"); if (mode == PurchaseMode.RANDOM) { Context.Respond("Make sure to check up your chances with '!gps list chances' to not get disappointed!"); } cooldownManager.StartCooldown(cooldownKey, commandKey, 30 * 1000); return(false); }