using Dalamud.Configuration; using Dalamud.Plugin; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace NoSoliciting { [Serializable] public class PluginConfiguration : IPluginConfiguration { [NonSerialized] private DalamudPluginInterface pi; public int Version { get; set; } = 1; [Obsolete("Use EnabledFilters")] public bool FilterChat { get; set; } = true; [Obsolete("Use EnabledFilters")] public bool FilterFCRecruitments { get; set; } = false; [Obsolete("Use EnabledFilters")] public bool FilterChatRPAds { get; set; } = false; [Obsolete("Use EnabledFilters")] public bool FilterPartyFinder { get; set; } = true; [Obsolete("Use EnabledFilters")] public bool FilterPartyFinderRPAds { get; set; } = false; public Dictionary FilterStatus { get; private set; } = new Dictionary(); public bool AdvancedMode { get; set; } = false; public bool CustomChatFilter { get; set; } = false; public List ChatSubstrings { get; } = new List(); public List ChatRegexes { get; } = new List(); [JsonIgnore] public List CompiledChatRegexes { get; private set; } = new List(); public bool CustomPFFilter { get; set; } = false; public List PFSubstrings { get; } = new List(); public List PFRegexes { get; } = new List(); [JsonIgnore] public List CompiledPFRegexes { get; private set; } = new List(); public bool FilterHugeItemLevelPFs { get; set; } = false; public void Initialise(DalamudPluginInterface pi) { this.pi = pi ?? throw new ArgumentNullException(nameof(pi), "DalamudPluginInterface cannot be null"); this.CompileRegexes(); } public void Save() { this.pi.SavePluginConfig(this); } public void CompileRegexes() { this.CompiledChatRegexes = this.ChatRegexes .Select(reg => new Regex(reg, RegexOptions.Compiled)) .ToList(); this.CompiledPFRegexes = this.PFRegexes .Select(reg => new Regex(reg, RegexOptions.Compiled)) .ToList(); } } }