public static void Run(string fileName) { try { IdListObject idlist; switch (fileName) { case SettingsFile: var m = JsonConvert.DeserializeObject <__RootObject>(FilterComments.Run(SettingsFile)); LocalVersion = m.General.Version; CmdCommandCharacter = m.General.CommandCharacter; DownloadIdList = m.General.DownloadIDList; TimestampFormat = m.General.TimestapFormat; MsgSayColor = m.General.MsgSayColor; MsgUnknownCommand = m.General.DisplayUnknownCommandMessage; VoteKickDisabled = m.General.VoteKickDisabled; ShowDMGMessage = m.General.ShowDMGMessage; DebugLevel = m.General.DebugLevel; EnableDiscordWebhook_Ban = m.General.EnableDiscordWebhook_Ban; if (EnableDiscordWebhook_Ban && string.IsNullOrEmpty(m.General.DiscordWebhook_Ban.Trim())) { Debug.Log("[ERROR] Discord webhook_Ban is empty but EnableDiscordWebhook_Ban is true! Disabling webhook_Ban."); EnableDiscordWebhook_Ban = false; } else { DiscordWebhook_Ban = m.General.DiscordWebhook_Ban; } EnableDiscordWebhook_Report = m.General.EnableDiscordWebhook_Report; if (EnableDiscordWebhook_Report && string.IsNullOrEmpty(m.General.DiscordWebhook_Report.Trim())) { Debug.Log("[ERROR] Discord webhook_Report is empty but EnableDiscordWebhook_Report is true! Disabling webhook_Report."); EnableDiscordWebhook_Report = false; } else { DiscordWebhook_Report = m.General.DiscordWebhook_Report; } BlockBanButtonTabMenu = m.General.BlockBanButtonTabMenu; blockLicenseRemoved = m.General.BlockLicenseRemoved; MessagesAllowedPerSecond = m.General.MessagesAllowedPerSecond; TimeBetweenDelay = m.General.TimeBetweenDelay; WipePassword = m.General.WipePassword; infoColor = m.MessageColors.Info; errorColor = m.MessageColors.Error; warningColor = m.MessageColors.Warning; argColor = m.MessageColors.Arg; MsgNoPerm = m.Messages.NoPerm; MsgDiscord = m.Messages.DiscordLink; MsgSayPrefix = m.Messages.MsgSayPrefix; DisabledCommand = $"<color={errorColor}>{m.Messages.DisabledCommand}</color>"; PlayerIsAFK = $"<color={warningColor}>{m.Messages.PlayerIsAFK}</color>"; SelfIsMuted = $"<color={errorColor}>{m.Messages.SelfIsMuted}</color>"; ArgRequired = $"<color={errorColor}>{m.Messages.ArgRequired}</color>"; NotFoundOnline = $"<color={errorColor}>{m.Messages.NotFoundOnline}</color>"; NotFoundOnlineIdOnly = $"<color={errorColor}>{m.Messages.NotFoundOnlineIdOnly}</color>"; AdminSearchingInv = $"<color={errorColor}>{m.Messages.AdminSearchingInv}</color>"; PlayerMessage = m.Messages.PlayerMessage; AdminMessage = m.Messages.AdminMessage; AdminChatMessage = m.Messages.AdminChatMessage; MsgNoPermJob = $"<color={errorColor}>{m.Messages.MsgNoPermJob}</color>"; BlockedItemMessage = $"<color={errorColor}>{m.Messages.BlockedItem}</color>"; MsgNoWantedAllowed = $"<color={errorColor}>{m.Messages.MsgNoWantedAllowed}</color>"; MsgNoCuffedAllowed = $"<color={errorColor}>{m.Messages.MsgNoCuffedAllowed}</color>"; MsgNoJailAllowed = $"<color={errorColor}>{m.Messages.MsgNoJailAllowed}</color>"; MeMessage = m.Messages.MeMessage; AccessMoneyMenu = m.FunctionUI.AccessMoneyMenu; AccessItemMenu = m.FunctionUI.AccessItemMenu; AccessSetHPMenu = m.FunctionUI.AccessSetHPMenu; AccessSetStatsMenu = m.FunctionUI.AccessSetStatsMenu; AccessCWMenu = m.FunctionUI.AccessCWMenu; ReportReasons = new string[] { m.ReportOptions.F2, m.ReportOptions.F3, m.ReportOptions.F4, m.ReportOptions.F5, m.ReportOptions.F6, m.ReportOptions.F7, m.ReportOptions.F8, m.ReportOptions.F9, m.ReportOptions.F10 }; // Softcode this someday Jobs = new string[] { m.JobIndexArray.Citizen, m.JobIndexArray.Criminal, m.JobIndexArray.Prisoner, m.JobIndexArray.Police, m.JobIndexArray.Paramedic, m.JobIndexArray.Firefighter, m.JobIndexArray.Rojo_Loco, m.JobIndexArray.Green_St_Fam, m.JobIndexArray.Borgata_Blue, m.JobIndexArray.Mayor, m.JobIndexArray.DeliveryDriver, m.JobIndexArray.TaxiDriver, m.JobIndexArray.SpecOps }; BlockedItems = m.BlockedItems; EnableBlockSpawnBot = m.Misc.EnableBlockSpawnBot; LanguageBlock = m.Misc.EnableLanguageBlock; ChatBlock = m.Misc.EnableChatBlock; CheckBannedEnabled = m.Misc.CheckBannedEnabled; TimeBetweenAnnounce = m.Misc.TimeBetweenAnnounce; Variables.Announcer.Interval = TimeBetweenAnnounce; TimescaleDisabled = m.Misc.TimescaleDisabled; if (m.Misc.EnableBlockSpawnBot) { BlockedSpawnIds = m.Misc.BlockSpawnBot.Split(',').Select(int.Parse).ToArray(); } GodModeLevel = m.Misc.GodModeLevel; ShowJailMessage = m.Misc.ShowJailMessage; BlockSuicide = m.Misc.BlockSuicide; BlockMissions = m.Misc.BlockMissions; ProximityChat = m.Misc.ProximityChat; LocalChatMute = m.Misc.LocalChatMute; LocalChatMe = m.Misc.LocalChatMe; foreach (var currJob in m.WhitelistedJobs) { if (WhitelistedJobs.ContainsKey(currJob.JobIndex)) { Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] WhitelistedJobs already contains a item with the key '{currJob.JobIndex}'! (Did you make two objects with the same JobIndex?)"); continue; } WhitelistedJobs.Add(currJob.JobIndex, currJob.Whitelisted); } RegisterCommands.Run(m.Commands); break; case IdListItemsFile: idlist = JsonConvert.DeserializeObject <IdListObject>(FilterComments.Run(IdListItemsFile)); IDs_Items = idlist.items.Select(x => x.gameid).ToArray(); break; case IdListVehicleFile: idlist = JsonConvert.DeserializeObject <IdListObject>(FilterComments.Run(IdListVehicleFile)); IDs_Vehicles = idlist.items.Select(x => x.gameid).ToArray(); break; case AnnouncementsFile: Variables.Announcer.Announcements = File.ReadAllLines(fileName).ToList(); break; case RulesFile: Rules = File.ReadAllText(fileName); break; case GodListFile: GodListPlayers = File.ReadAllLines(fileName).ToList(); break; case AfkListFile: AfkPlayers = File.ReadAllLines(fileName).ToList(); break; case MuteListFile: MutePlayers = File.ReadAllLines(fileName).ToList(); break; default: break; } } catch (Exception ex) { ErrorLogging.Run(ex); } }
public static void Run() { try { // this really needs some improvement // I don't know when I added that comment but seriously I should really redo this method.. whenever I have time // Every time I have to change something in this file it reminds me again that I should change this somehow.. I just don't know how. // lol yup still here.. f**k. // shrugs if (!Directory.Exists(FileDirectory)) { Directory.CreateDirectory(FileDirectory); Debug.Log(FileDirectory + " Does not exist! Creating one."); } if (!Directory.Exists(LogDirectory)) { Directory.CreateDirectory(LogDirectory); Debug.Log(LogDirectory + " Does not exist! Creating one."); } if (!Directory.Exists(KitDirectory)) { Directory.CreateDirectory(KitDirectory); Debug.Log(KitDirectory + " Does not exist! Creating one."); } if (!Directory.Exists(WarpDirectory)) { Directory.CreateDirectory(WarpDirectory); Debug.Log(WarpDirectory + " Does not exist! Creating one."); } if (!File.Exists(AutoReloader)) { File.Create(AutoReloader).Close(); Debug.Log(AutoReloader + " Does not exist! Creating one."); } if (!File.Exists(AfkListFile)) { File.Create(AfkListFile).Close(); Debug.Log(AfkListFile + " Does not exist! Creating one."); } if (!File.Exists(MuteListFile)) { File.Create(MuteListFile).Close(); Debug.Log(MuteListFile + " Does not exist! Creating one."); } if (!File.Exists(ChatBlockFile)) { File.Create(ChatBlockFile).Close(); CreateFile.Run(ChatBlockFile); Debug.Log(ChatBlockFile + " Does not exist! Creating one."); } if (!File.Exists(GodListFile)) { File.Create(GodListFile).Close(); Debug.Log(GodListFile + " Does not exist! Creating one."); } if (!File.Exists(IpListFile)) { File.Create(IpListFile).Close(); Debug.Log(IpListFile + " Does not exist! Creating one."); } if (!File.Exists(LanguageBlockFile)) { File.Create(LanguageBlockFile).Close(); CreateFile.Run(LanguageBlockFile); Debug.Log(LanguageBlockFile + " Does not exist! Creating one."); } if (!File.Exists(MuteListFile)) { File.Create(MuteListFile).Close(); Debug.Log(MuteListFile + " Does not exist! Creating one."); } if (!File.Exists(SettingsFile)) { File.Create(SettingsFile).Close(); CreateFile.Run(SettingsFile); Debug.Log(SettingsFile + " Does not exist! Creating one."); } if (!File.Exists(CustomGroupsFile)) { File.Create(CustomGroupsFile).Close(); CreateFile.Run(CustomGroupsFile); Debug.Log(CustomGroupsFile + " Does not exist! Creating one."); } if (!File.Exists(CustomCommandsFile)) { File.Create(CustomCommandsFile).Close(); CreateFile.Run(CustomCommandsFile); Debug.Log(CustomCommandsFile + " Does not exist! Creating one."); } if (!File.Exists(AnnouncementsFile)) { File.Create(AnnouncementsFile).Close(); Debug.Log(AnnouncementsFile + " Does not exist! Creating one."); } if (!File.Exists(LogFile)) { File.Create(LogFile).Close(); Debug.Log(LogFile + " Does not exist! Creating one."); } if (!File.Exists(ChatLogFile)) { File.Create(ChatLogFile).Close(); Debug.Log(ChatLogFile + " Does not exist! Creating one."); } if (!File.Exists(CommandLogFile)) { File.Create(CommandLogFile).Close(); Debug.Log(CommandLogFile + " Does not exist! Creating one."); } } catch (Exception ex) { ErrorLogging.Run(ex); } }
public static bool SvGlobalChatMessage(SvPlayer player, ref string message) { try { var tempMessage = message; if (HandleSpam.Run(player, tempMessage)) { return(true); } //Message Logging if (!MutePlayers.Contains(player.playerData.username)) { LogMessage.Run(player, message); } if (message.StartsWith(CmdCommandCharacter, StringComparison.CurrentCulture)) { if (OnCommand(player, ref message)) { return(true); } } //Checks if the player is muted. if (MutePlayers.Contains(player.playerData.username)) { player.SendChatMessage(SelfIsMuted); return(true); } //Checks if the message contains a username that is AFK. if (AfkPlayers.Any(message.Contains)) { player.SendChatMessage(PlayerIsAFK); } var shPlayer = player.player; if (!PlayerList[shPlayer.ID].ChatEnabled) { player.SendChatMessage($"<color={warningColor}>Please enable your chat again by typing</color> <color={argColor}>{CmdCommandCharacter}{CmdToggleChat}</color><color={warningColor}>.</color>"); return(true); } if (PlayerList[shPlayer.ID].StaffChatEnabled) { SendChatMessageToAdmins.Run(PlaceholderParser.ParseUserMessage(shPlayer, AdminChatMessage, message)); return(true); } foreach (var curr in Groups) { if (curr.Value.Users.Contains(player.playerData.username)) { SendChatMessage.Run(PlaceholderParser.ParseUserMessage(shPlayer, curr.Value.Message, message)); return(true); } } if (player.player.admin) { SendChatMessage.Run(PlaceholderParser.ParseUserMessage(shPlayer, AdminMessage, message)); return(true); } SendChatMessage.Run(PlaceholderParser.ParseUserMessage(shPlayer, PlayerMessage, message)); } catch (Exception ex) { ErrorLogging.Run(ex); } return(true); }