public void Execute(IJobExecutionContext context) { var offensesCopy = new CheatingOffenseEntry[Offenses.Count]; lock (Offenses) { Offenses.Values.CopyTo(offensesCopy, 0); } foreach (var offense in offensesCopy.Where(offense => offense.IsExpired())) { ExpireEntry(offense); } if (!m_chr.IsAlive) { TimerManager.Instance.CancelTask(m_invalidationTaskToken); } }
public void RegisterOffense(CheatingOffense offense, string param) { var chrhardref = (MapleCharacter)m_chr.Target; if (chrhardref == null || !offense.Enabled) { return; } CheatingOffenseEntry entry; if (Offenses.TryGetValue(offense, out entry) && entry.IsExpired()) { ExpireEntry(entry); entry = null; } if (entry == null) { entry = new CheatingOffenseEntry(offense, chrhardref); } if (param != null) { entry.Param = param; } entry.IncrementCount(); if (offense.ShouldAutoban(entry.Count)) { AutobanManager.Instance.Autoban(chrhardref.Client, nameof(offense)); } if (Offenses.ContainsKey(offense)) { Offenses[offense] = entry; } else { Offenses.Add(offense, entry); } CheatingOffensePersister.Instance.PersistEntry(entry); }
public int GetPoints() { var ret = 0; var offensesCopy = new CheatingOffenseEntry[Offenses.Count]; lock (Offenses) { Offenses.Values.CopyTo(offensesCopy, 0); } foreach (var entry in offensesCopy) { if (entry.IsExpired()) { ExpireEntry(entry); } else { ret += entry.Points; } } return(ret); }
public static void ExpireEntry(CheatingOffenseEntry coe) { Offenses.Remove(coe.Offense); }