/// <summary> /// Infract the Player with the amount of points. /// </summary> /// <param name="Player">Player to infract.</param> /// <param name="Points">Amount of points to infract.</param> public static void AddInfractionCount(this Player Player, int Points) { if (Player.IsSwearInfracted()) { SwearInfractionList SwearInfractionList = Player.GetSwearInfractionList(); SwearInfractionList.Name = Player.Name; if ((DateTime.Now - SwearInfractionList.StartTime).TotalDays >= Core.Setting.SwearInfractionReset) { SwearInfractionList.Points = Points; } else { if (SwearInfractionList.Points >= Core.Setting.SwearInfractionCap) { SwearInfractionList.Points = 0; } SwearInfractionList.Points += Points; } SwearInfractionList.StartTime = DateTime.Now; if (SwearInfractionList.Points >= Core.Setting.SwearInfractionCap) { SwearInfractionList.Points = Core.Setting.SwearInfractionCap; SwearInfractionList.Muted += 1; } Core.Setting.Save(); } else { Core.Setting.SwearInfractionListData.Add(new SwearInfractionList(Player.Name, Player.GameJoltID, Points, 0, DateTime.Now)); Core.Setting.Save(); } }
/// <summary> /// Defract the Player with the amount of points. /// </summary> /// <param name="Player">Player to defract.</param> /// <param name="Points">Amount of points to defract.</param> public static void RemoveInfractionCount(this Player Player, int Points) { if (Player.IsSwearInfracted()) { SwearInfractionList SwearInfractionList = Player.GetSwearInfractionList(); SwearInfractionList.Name = Player.Name; if ((DateTime.Now - SwearInfractionList.StartTime).TotalDays >= Core.Setting.SwearInfractionReset) { SwearInfractionList.Points = 0; } else { SwearInfractionList.Points -= Points; SwearInfractionList.Points = SwearInfractionList.Points.Clamp(0, int.MaxValue); } SwearInfractionList.StartTime = DateTime.Now; Core.Setting.Save(); } }