/// <summary> /// Load a single setting from INI file or command-line argument /// </summary> /// <param name="section">Settings section</param> /// <param name="argName">Setting name</param> /// <param name="argValue">Setting value</param> /// <returns>TRUE if setting was valid</returns> private static bool LoadSingleSetting(Section section, string argName, string argValue) { switch (section) { case Section.Main: switch (argName.ToLower()) { case "login": Login = argValue; return(true); case "password": Password = argValue; return(true); case "type": AccountType = argValue == "mojang" ? ProtocolHandler.AccountType.Mojang : ProtocolHandler.AccountType.Microsoft; return(true); case "method": LoginMethod = argValue.ToLower() == "browser" ? "browser" : "mcc"; return(true); case "serverip": if (!SetServerIP(argValue)) { ServerAliasTemp = argValue; } return(true); case "singlecommand": SingleCommand = argValue; return(true); case "language": Language = argValue; return(true); case "consoletitle": ConsoleTitle = argValue; return(true); case "timestamps": ConsoleIO.EnableTimestamps = str2bool(argValue); return(true); case "exitonfailure": interactiveMode = !str2bool(argValue); return(true); case "playerheadicon": playerHeadAsIcon = str2bool(argValue); return(true); case "chatbotlogfile": chatbotLogFile = argValue; return(true); case "mcversion": ServerVersion = argValue; return(true); case "messagecooldown": messageCooldown = TimeSpan.FromSeconds(str2int(argValue)); return(true); case "scriptcache": CacheScripts = str2bool(argValue); return(true); case "showsystemmessages": DisplaySystemMessages = str2bool(argValue); return(true); case "showxpbarmessages": DisplayXPBarMessages = str2bool(argValue); return(true); case "showchatlinks": DisplayChatLinks = str2bool(argValue); return(true); case "terrainandmovements": TerrainAndMovements = str2bool(argValue); return(true); case "entityhandling": EntityHandling = str2bool(argValue); return(true); case "enableentityhandling": EntityHandling = str2bool(argValue); return(true); case "inventoryhandling": InventoryHandling = str2bool(argValue); return(true); case "privatemsgscmdname": PrivateMsgsCmdName = argValue.ToLower().Trim(); return(true); case "autorespawn": AutoRespawn = str2bool(argValue); return(true); // Backward compatible so people can still enable debug with old config format case "debugmessages": DebugMessages = str2bool(argValue); return(true); case "minecraftrealms": MinecraftRealmsEnabled = str2bool(argValue); return(true); case "botowners": Bots_Owners.Clear(); string[] names = argValue.ToLower().Split(','); if (!argValue.Contains(",") && argValue.ToLower().EndsWith(".txt") && File.Exists(argValue)) { names = File.ReadAllLines(argValue); } foreach (string name in names) { if (!String.IsNullOrWhiteSpace(name)) { Bots_Owners.Add(name.Trim()); } } return(true); case "internalcmdchar": switch (argValue.ToLower()) { case "none": internalCmdChar = ' '; break; case "slash": internalCmdChar = '/'; break; case "backslash": internalCmdChar = '\\'; break; } return(true); case "sessioncache": if (argValue == "none") { SessionCaching = CacheType.None; } else if (argValue == "memory") { SessionCaching = CacheType.Memory; } else if (argValue == "disk") { SessionCaching = CacheType.Disk; } return(true); case "accountlist": if (File.Exists(argValue)) { foreach (string account_line in File.ReadAllLines(argValue)) { //Each line contains account data: 'Alias,Login,Password' string[] account_data = account_line.Split('#')[0].Trim().Split(','); if (account_data.Length == 3) { Accounts[account_data[0].ToLower()] = new KeyValuePair <string, string>(account_data[1], account_data[2]); } } //Try user value against aliases after load SetAccount(Login); } return(true); case "serverlist": if (File.Exists(argValue)) { //Backup current server info string server_host_temp = ServerIP; ushort server_port_temp = ServerPort; foreach (string server_line in File.ReadAllLines(argValue)) { //Each line contains server data: 'Alias,Host:Port' string[] server_data = server_line.Split('#')[0].Trim().Split(','); server_data[0] = server_data[0].ToLower(); if (server_data.Length == 2 && server_data[0] != "localhost" && !server_data[0].Contains('.') && SetServerIP(server_data[1])) { Servers[server_data[0]] = new KeyValuePair <string, ushort>(ServerIP, ServerPort); } } //Restore current server info ServerIP = server_host_temp; ServerPort = server_port_temp; //Try server value against aliases after load if (!String.IsNullOrEmpty(ServerAliasTemp)) { SetServerIP(ServerAliasTemp); ServerAliasTemp = null; } } return(true); case "brandinfo": switch (argValue.Trim().ToLower()) { case "mcc": BrandInfo = MCCBrandInfo; break; case "vanilla": BrandInfo = "vanilla"; break; default: BrandInfo = null; break; } return(true); case "resolvesrvrecords": if (argValue.Trim().ToLower() == "fast") { ResolveSrvRecords = true; ResolveSrvRecordsShortTimeout = true; } else { ResolveSrvRecords = str2bool(argValue); ResolveSrvRecordsShortTimeout = false; } return(true); case "mcforge": if (argValue.ToLower() == "auto") { ServerAutodetectForge = true; ServerForceForge = false; } else { ServerAutodetectForge = false; ServerForceForge = str2bool(argValue); } return(true); } break; case Section.Logging: switch (argName.ToLower()) { case "debugmessages": DebugMessages = str2bool(argValue); return(true); case "chatmessages": ChatMessages = str2bool(argValue); return(true); case "warningmessages": WarningMessages = str2bool(argValue); return(true); case "errormessages": ErrorMessages = str2bool(argValue); return(true); case "infomessages": InfoMessages = str2bool(argValue); return(true); case "chatfilter": ChatFilter = new Regex(argValue); return(true); case "debugfilter": DebugFilter = new Regex(argValue); return(true); case "filtermode": if (argValue.ToLower().StartsWith("white")) { FilterMode = FilterModeEnum.Whitelist; } else { FilterMode = FilterModeEnum.Blacklist; } return(true); case "logtofile": LogToFile = str2bool(argValue); return(true); case "logfile": LogFile = argValue; return(true); case "prependtimestamp": PrependTimestamp = str2bool(argValue); return(true); } break; case Section.Alerts: switch (argName.ToLower()) { case "enabled": Alerts_Enabled = str2bool(argValue); return(true); case "alertsfile": Alerts_MatchesFile = argValue; return(true); case "excludesfile": Alerts_ExcludesFile = argValue; return(true); case "beeponalert": Alerts_Beep_Enabled = str2bool(argValue); return(true); } break; case Section.AntiAFK: switch (argName.ToLower()) { case "enabled": AntiAFK_Enabled = str2bool(argValue); return(true); case "delay": AntiAFK_Delay = str2int(argValue); return(true); case "command": AntiAFK_Command = argValue == "" ? "/ping" : argValue; return(true); } break; case Section.AutoRelog: switch (argName.ToLower()) { case "enabled": AutoRelog_Enabled = str2bool(argValue); return(true); case "retries": AutoRelog_Retries = str2int(argValue); return(true); case "ignorekickmessage": AutoRelog_IgnoreKickMessage = str2bool(argValue); return(true); case "kickmessagesfile": AutoRelog_KickMessagesFile = argValue; return(true); case "delay": string[] delayParts = argValue.Split('-'); if (delayParts.Length == 1) { AutoRelog_Delay_Min = str2int(delayParts[0]); AutoRelog_Delay_Max = AutoRelog_Delay_Min; } else { AutoRelog_Delay_Min = str2int(delayParts[0]); AutoRelog_Delay_Max = str2int(delayParts[1]); } return(true); } break; case Section.ChatLog: switch (argName.ToLower()) { case "enabled": ChatLog_Enabled = str2bool(argValue); return(true); case "timestamps": ChatLog_DateTime = str2bool(argValue); return(true); case "filter": ChatLog_Filter = ChatBots.ChatLog.str2filter(argValue); return(true); case "logfile": ChatLog_File = argValue; return(true); } break; case Section.Hangman: switch (argName.ToLower()) { case "enabled": Hangman_Enabled = str2bool(argValue); return(true); case "english": Hangman_English = str2bool(argValue); return(true); case "wordsfile": Hangman_FileWords_EN = argValue; return(true); case "fichiermots": Hangman_FileWords_FR = argValue; return(true); } break; case Section.ScriptScheduler: switch (argName.ToLower()) { case "enabled": ScriptScheduler_Enabled = str2bool(argValue); return(true); case "tasksfile": ScriptScheduler_TasksFile = argValue; return(true); } break; case Section.RemoteControl: switch (argName.ToLower()) { case "enabled": RemoteCtrl_Enabled = str2bool(argValue); return(true); case "autotpaccept": RemoteCtrl_AutoTpaccept = str2bool(argValue); return(true); case "tpaccepteveryone": RemoteCtrl_AutoTpaccept_Everyone = str2bool(argValue); return(true); } break; case Section.ChatFormat: switch (argName.ToLower()) { case "builtins": ChatFormat_Builtins = str2bool(argValue); return(true); case "public": ChatFormat_Public = new Regex(argValue); return(true); case "private": ChatFormat_Private = new Regex(argValue); return(true); case "tprequest": ChatFormat_TeleportRequest = new Regex(argValue); return(true); } break; case Section.Proxy: switch (argName.ToLower()) { case "enabled": ProxyEnabledLogin = ProxyEnabledIngame = str2bool(argValue); if (argValue.Trim().ToLower() == "login") { ProxyEnabledLogin = true; } return(true); case "type": argValue = argValue.ToLower(); if (argValue == "http") { proxyType = Proxy.ProxyHandler.Type.HTTP; } else if (argValue == "socks4") { proxyType = Proxy.ProxyHandler.Type.SOCKS4; } else if (argValue == "socks4a") { proxyType = Proxy.ProxyHandler.Type.SOCKS4a; } else if (argValue == "socks5") { proxyType = Proxy.ProxyHandler.Type.SOCKS5; } return(true); case "server": string[] host_splitted = argValue.Split(':'); if (host_splitted.Length == 1) { ProxyHost = host_splitted[0]; ProxyPort = 80; } else if (host_splitted.Length == 2) { ProxyHost = host_splitted[0]; ProxyPort = str2int(host_splitted[1]); } return(true); case "username": ProxyUsername = argValue; return(true); case "password": ProxyPassword = argValue; return(true); } break; case Section.AppVars: SetVar(argName, argValue); return(true); case Section.AutoRespond: switch (argName.ToLower()) { case "enabled": AutoRespond_Enabled = str2bool(argValue); return(true); case "matchesfile": AutoRespond_Matches = argValue; return(true); } break; case Section.AutoAttack: switch (argName.ToLower()) { case "enabled": AutoAttack_Enabled = str2bool(argValue); return(true); case "mode": AutoAttack_Mode = argValue.ToLower(); return(true); case "priority": AutoAttack_Priority = argValue.ToLower(); return(true); case "cooldownseconds": if (argValue.ToLower() == "auto") { AutoAttack_OverrideAttackSpeed = false; } else { AutoAttack_OverrideAttackSpeed = true; AutoAttack_CooldownSeconds = str2float(argValue); } return(true); } break; case Section.AutoFishing: switch (argName.ToLower()) { case "enabled": AutoFishing_Enabled = str2bool(argValue); return(true); case "antidespawn": AutoFishing_Antidespawn = str2bool(argValue); return(true); } break; case Section.AutoEat: switch (argName.ToLower()) { case "enabled": AutoEat_Enabled = str2bool(argValue); return(true); case "threshold": AutoEat_hungerThreshold = str2int(argValue); return(true); } break; case Section.AutoCraft: switch (argName.ToLower()) { case "enabled": AutoCraft_Enabled = str2bool(argValue); return(true); case "configfile": AutoCraft_configFile = argValue; return(true); } break; case Section.AutoDrop: switch (argName.ToLower()) { case "enabled": AutoDrop_Enabled = str2bool(argValue); return(true); case "mode": AutoDrop_Mode = argValue; return(true); case "items": AutoDrop_items = argValue; return(true); } break; case Section.MCSettings: switch (argName.ToLower()) { case "enabled": MCSettings_Enabled = str2bool(argValue); return(true); case "locale": MCSettings_Locale = argValue; return(true); case "difficulty": switch (argValue.ToLower()) { case "peaceful": MCSettings_Difficulty = 0; break; case "easy": MCSettings_Difficulty = 1; break; case "normal": MCSettings_Difficulty = 2; break; case "difficult": MCSettings_Difficulty = 3; break; } return(true); case "renderdistance": MCSettings_RenderDistance = 2; if (argValue.All(Char.IsDigit)) { MCSettings_RenderDistance = (byte)str2int(argValue); } else { switch (argValue.ToLower()) { case "tiny": MCSettings_RenderDistance = 2; break; case "short": MCSettings_RenderDistance = 4; break; case "medium": MCSettings_RenderDistance = 8; break; case "far": MCSettings_RenderDistance = 16; break; } } return(true); case "chatmode": switch (argValue.ToLower()) { case "enabled": MCSettings_ChatMode = 0; break; case "commands": MCSettings_ChatMode = 1; break; case "disabled": MCSettings_ChatMode = 2; break; } return(true); case "chatcolors": MCSettings_ChatColors = str2bool(argValue); return(true); case "skin_cape": MCSettings_Skin_Cape = str2bool(argValue); return(true); case "skin_jacket": MCSettings_Skin_Jacket = str2bool(argValue); return(true); case "skin_sleeve_left": MCSettings_Skin_Sleeve_Left = str2bool(argValue); return(true); case "skin_sleeve_right": MCSettings_Skin_Sleeve_Right = str2bool(argValue); return(true); case "skin_pants_left": MCSettings_Skin_Pants_Left = str2bool(argValue); return(true); case "skin_pants_right": MCSettings_Skin_Pants_Right = str2bool(argValue); return(true); case "skin_hat": MCSettings_Skin_Hat = str2bool(argValue); return(true); case "main_hand": switch (argValue.ToLower()) { case "left": MCSettings_MainHand = 0; break; case "right": MCSettings_MainHand = 1; break; } return(true); } break; case Section.Mailer: switch (argName.ToLower()) { case "enabled": Mailer_Enabled = str2bool(argValue); return(true); case "database": Mailer_DatabaseFile = argValue; return(true); case "ignorelist": Mailer_IgnoreListFile = argValue; return(true); case "publicinteractions": Mailer_PublicInteractions = str2bool(argValue); return(true); case "maxmailsperplayer": Mailer_MaxMailsPerPlayer = str2int(argValue); return(true); case "maxdatabasesize": Mailer_MaxDatabaseSize = str2int(argValue); return(true); case "retentiondays": Mailer_MailRetentionDays = str2int(argValue); return(true); } break; case Section.ReplayMod: switch (argName.ToLower()) { case "enabled": ReplayMod_Enabled = str2bool(argValue); return(true); case "backupinterval": ReplayMod_BackupInterval = str2int(argValue); return(true); } break; } return(false); }
public static SearchRequest AddFilter(this SearchRequest request, GetSelectableColumnsResponse allColumns, string uniqueColumnName, object value, FilterModeEnum mode = FilterModeEnum.Equal) { if (request.Filters == null) { request.Filters = new List <SearchRequestFilter>(); } var column = allColumns.Data.Where(x => x.UniqueName == uniqueColumnName).Select(x => new SelectedColumn(x.Id)).FirstOrDefault(); request.Filters.Add(new SearchRequestFilter() { ColumnId = column.ColumnId, Mode = mode, Values = new List <string>() { value.ToString() } }); return(request); }