protected override void LoadDefaultConfig() { // Options Config["Clan Protection (true/false)"] = clanProtection = GetConfig("Clan Protection (true/false)", true); Config["Friend Protection (true/false)"] = friendProtection = GetConfig("Friend Protection (true/false)", true); Config["Item Stealing (true/false)"] = itemStealing = GetConfig("Item Stealing (true/false)", true); Config["Money Stealing (true/false)"] = moneyStealing = GetConfig("Money Stealing (true/false)", true); Config["Point Stealing (true/false)"] = pointStealing = GetConfig("Point Stealing (true/false)", true); // Settings Config["Cooldown (Seconds, 0 to Disable)"] = usageCooldown = GetConfig("Cooldown (Seconds, 0 to Disable)", 30); Config["Percent from Awake (0 - 100)"] = percentAwake = GetConfig("Percent from Awake (0 - 100)", 25f); Config["Percent from Sleeping (0 - 100)"] = percentSleeping = GetConfig("Percent from Sleeping (0 - 100)", 50f); // Cleanup Config.Remove("ClanProtection"); Config.Remove("FriendProtection"); Config.Remove("ItemStealing"); Config.Remove("MoneyStealing"); Config.Remove("PercentAwake"); Config.Remove("PercentSleeping"); Config.Remove("PointStealing"); Config.Remove("UsageCooldown"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["Cargo Plane Alerts (true/false)"] = cargoPlaneAlerts = GetConfig("Cargo Plane Alerts (true/false)", true); Config["Helicopter Alerts (true/false)"] = helicopterAlerts = GetConfig("Helicopter Alerts (true/false)", true); Config["Show Coordinates (true/false)"] = showCoordinates = GetConfig("Show Coordinates (true/false)", true); Config["Supply Drop Alerts (true/false)"] = supplyDropAlerts = GetConfig("Supply Drop Alerts (true/false)", true); Config["Supply Drop Arrow On Landing (true/false)"] = arrowOnLanding = GetConfig("Supply Drop Arrow On Landing (true/false)", true); Config["Supply Drop Arrow Until Empty (true/false)"] = arrowUntilEmpty = GetConfig("Supply Drop Arrow Until Empty (true/false)", true); // Settings //Config["Arrow Color (Default #ffffff)"] = arrowColor = GetConfig("Arrow Color (Default #ffffff)", "#ffffff"); Config["Arrow Length (Default 15)"] = arrowLength = GetConfig("Arrow Length (Default 15)", 15); Config["Arrow Size (Default 4)"] = arrowSize = GetConfig("Arrow Size (Default 4)", 4); Config["Arrow Time (Seconds, Default 60))"] = arrowTime = GetConfig("Arrow Time (Seconds, Default 60)", 60); // Cleanup Config.Remove("Show Coordonates (true/false)"); Config.Remove("HelicopterAlerts"); Config.Remove("SupplyDropAlerts"); Config.Remove("SupplyDropArrow"); Config.Remove("SupplyDropArrowLength"); Config.Remove("SupplyDropArrowSize"); Config.Remove("SupplyDropArrowTime"); SaveConfig(); }
protected override void LoadDefaultConfig() { foreach (var grade in Enum.GetNames(typeof(BuildingGrade.Enum))) { if (grade.Equals("None") || grade.Equals("Count")) { continue; } Config[$"Refund {grade} (true/false)"] = GetConfig($"Refund {grade} (true/false)", true); } // Options Config["Refund for Demolish (true/false)"] = demolishRefunds = GetConfig("Refund for Demolish (true/false)", true); Config["Refund for Upgrade (true/false)"] = upgradeRefunds = GetConfig("Refund for Upgrade (true/false)", true); // Cleanup Config.Remove("DemolishRefunds"); Config.Remove("UpgradeRefunds"); Config.Remove("RefundMetal"); Config.Remove("RefundStone"); Config.Remove("RefundTopTier"); Config.Remove("RefundTwigs"); Config.Remove("RefundWood"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["Cargo Plane Alerts (true/false)"] = cargoPlaneAlerts = GetConfig("Cargo Plane Alerts (true/false)", true); Config["Helicopter Alerts (true/false)"] = helicopterAlerts = GetConfig("Helicopter Alerts (true/false)", true); Config["Show Coordinates (true/false)"] = showCoordinates = GetConfig("Show Coordinates (true/false)", true); Config["Supply Drop Alerts (true/false)"] = supplyDropAlerts = GetConfig("Supply Drop Alerts (true/false)", true); Config["Cargoship Alerts (true/false)"] = cargoshipAlerts = GetConfig("Cargoship Alerts (true/false)", true); Config["CH47 Chinook Alerts (true/false)"] = chinookAlerts = GetConfig("CH47 Chinook Alerts (true/false)", true); Config["Player Supply Drop Alert (true/false)"] = playerSupplydropAlert = GetConfig("Player Supply Drop Alert (true/false)", true); Config["APC Bradley Alerts (true/false)"] = ApcBradleyAlerts = GetConfig("APC Bradley Alerts (true/false)", true); Config["Hackable Crate Alerts (true/false)"] = HackableAlerts = GetConfig("Hackable Crate Alerts (true/false)", true); Config["Hackable Player In Alert (true/false)"] = HackablePlayersAlert = GetConfig("Hackable Player In Alert (true/false)", true); // Cleanup Config.Remove("Show Coordonates (true/false)"); Config.Remove("HelicopterAlerts"); Config.Remove("CargoshipAlerts"); Config.Remove("SupplyDropAlerts"); Config.Remove("ChinookAlerts"); Config.Remove("PlayerSupplyDropAlert"); Config.Remove("ApcBradleyAlerts"); Config.Remove("HackableAlerts"); Config.Remove("HackablePlayersAlert"); SaveConfig(); }
protected override void LoadDefaultConfig() { Config["Disable Only On Constructions (true/false)"] = false; //Config["Allow On External Walls (true/false)"] = false; Config.Remove("BuildingBlockedMsg"); Config.Remove("DisableOnlyOnConstructions"); }
protected override void LoadDefaultConfig() { Config["Admin List Separate (true/false)"] = adminSeparate = GetConfig("Admin List Separate (true/false)", false); Config["Admin Color (Hex Format or Name)"] = adminColor = GetConfig("Admin Color (Hex Format or Name)", "e68c17"); // Cleanup Config.Remove("SeparateAdmin"); Config.Remove("AdminColor"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Settings Config["Loot All Delay (Seconds, 0 to Disable)"] = lootAllDelay = GetConfig("Loot All Delay (Seconds, 0 to Disable)", 0); Config["UI Style (center, lite, right)"] = uiStyle = GetConfig("UI Style (center, lite, right)", "right"); // Cleanup Config.Remove("LootAllowed"); Config.Remove("LootDelay"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["Log Usage (true/false)"] = logUsage = GetConfig("Log Usage (true/false)", true); Config["Show Messages (true/false)"] = showMessages = GetConfig("Show Messages (true/false)", true); // Cleanup Config.Remove("LogUsage"); Config.Remove("ShowMessages"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Settings Config["Cooldown (Seconds, 0 to Disable)"] = cooldown = GetConfig("Cooldown (Seconds, 0 to Disable)", 30); Config["Maximum Heal Amount (1 - Infinity)"] = maxAmount = GetConfig("Maximum Heal Amount (1 - Infinity)", 100); // Cleanup Config.Remove("MaxAmount"); Config.Remove("UsageCooldown"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Settings Config["Cooldown (Seconds, 0 to Disable)"] = cooldown = GetConfig("Cooldown (Seconds, 0 to Disable)", 30); Config["Damage Amount (0 to Disable)"] = damageAmount = GetConfig("Damage Amount (0 to Disable)", 5); // Cleanup Config.Remove("DamageAmount"); Config.Remove("UsageCooldown"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["Admin Excluded (true/false)"] = adminExcluded = GetConfig("Admin Excluded (true/false)", true); Config["Reset On Restart (true/false)"] = resetOnRestart = GetConfig("Reset On Restart (true/false)", false); // Cleanup Config.Remove("AdminExcluded"); Config.Remove("ResetOnRestart"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Settings Config["Health Amount"] = healAmount = GetConfig("Health Amount", 20f); Config["Hunger Amount"] = hungerAmount = GetConfig("Hunger Amount", 0f); Config["Thirst Amount"] = thirstAmount = GetConfig("Thirst Amount", 0f); // Cleanup Config.Remove("HealthAmount"); Config.Remove("HungerAmount"); Config.Remove("ThirstAmount"); SaveConfig(); }
void UpgradeConfig() { string cvKey = "config.version"; bool dirty = false; if (Config[cvKey] == null) { Config[cvKey] = 1; } else { try { var foo = (string)Config[cvKey]; Config[cvKey] = 2; dirty = true; } catch (InvalidCastException) { } // testing if it can be converted to a string or not. No need to change it because it's not a string. } int currentVersion = (int)Config[cvKey]; if (currentVersion < 2) { if (Config["show_own_damage"] != null) { Config["debug.show_own_damage"] = (bool)Config["show_own_damage"]; } else { Config["debug.show_own_damage"] = false; } Config.Remove("show_own_damage"); Config["permitted_only.enabled"] = false; dirty = true; } if (currentVersion < 3) { Puts(string.Format(lang.GetMessage("config.upgrading", this), 3)); Config.Remove("permitted_only.group"); Config[cvKey] = 3; dirty = true; } if (dirty) { SaveConfig(); } }
protected override void LoadDefaultConfig() { // Options Config["Force Server Language (true/false)"] = forceDefault = GetConfig("Force Server Language (true/false)", false); Config["Random Prefix Colors (true/false)"] = prefixColors = GetConfig("Random Prefix Colors (true/false)", true); Config["Show Original Message (true/false)"] = showOriginal = GetConfig("Show Original Message (true/false)", false); // Cleanup Config.Remove("ForceDefault"); Config.Remove("PrefixColors"); Config.Remove("ShowOriginal"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["Same Category Only (true/false)"] = sameCategory = GetConfig("Same Category Only (true/false)", true); // Settings Config["Item Exclusions"] = exclusions = GetConfig("Item Exclusions", new List <object> { "item.shortname", "otheritem.name" }); // Cleanup Config.Remove("ItemExclusions"); Config.Remove("UsePermissions"); SaveConfig(); }
void UpgradeConfig() { string configVersion = "config.version"; bool dirty = false; if (Config[configVersion] == null) { Config[configVersion] = 1; } else { try { var foo = (string)Config[configVersion]; Config[configVersion] = 2; dirty = true; } catch (InvalidCastException) { } // testing if it can be converted to a string or not. No need to change it because it's not a string. } if ((int)Config[configVersion] < 2) { LogWarning(string.Format(lang.GetMessage("config.upgrading", this), "1.1.2")); // Update the API endpoint string api_url = (string)Config["api_url"]; if (api_url == "http://poundbot.mrpoundsign.com/" || api_url == "http://api.poundbot.com/") { Config["api.url"] = "https://api.poundbot.com/"; } else { Config["api.url"] = (string)Config["api_url"]; } Config["api.key"] = (string)Config["api_key"]; Config.Remove("api_url"); Config.Remove("api_key"); Config["players.registered.group"] = "poundbot.registered"; Config[configVersion] = 2; dirty = true; } if (dirty) { SaveConfig(); } }
void OnServerInitialized() { permission.RegisterPermission("autogrades.all", this); permission.RegisterPermission("autogrades.1", this); permission.RegisterPermission("autogrades.2", this); permission.RegisterPermission("autogrades.3", this); permission.RegisterPermission("autogrades.4", this); permission.RegisterPermission("autogrades.nores", this); // config update from 0.0.3 var gperm = false; if (!LoadDefault && (Config["Language"] != null || Config["Messages"] != null)) { Config.Remove("Language"); Config["OldMessages"] = Config["Messages"]; // i don't want remove someone translation/customization without any warnings! Config.Remove("Messages"); // not sure if this is correct way of show warning, but it works. Interface.Oxide.LogInfo("[{0}] {1}", Title, "Config successfully updated!"); Interface.Oxide.LogWarning("[{0}] {1}", Title, "Please re-assign player rights! Old rights will not work!"); gperm = true; } if (Config["OldMessages"] != null) { Interface.Oxide.LogWarning("[{0}] {1}", Title, "Outdated messages detected!"); Interface.Oxide.LogWarning("[{0}] {1}", Title, "Please remove them from config after merge to oxide/lang file."); } // end of config update if (LoadDefault || Config["Block Construct and Refund"] == null || gperm) { permission.GrantGroupPermission("admin", "autogrades.all", this); permission.GrantGroupPermission("admin", "autogrades.nores", this); } ReadFromConfig <bool>("Block Construct and Refund", ref block); ReadFromConfig <string>("Command", ref cmdname); SaveConfig(); var command = Interface.Oxide.GetLibrary <Command>(); command.AddChatCommand(cmdname, this, "ChatBuildGrade"); }
protected override void LoadDefaultConfig() { // Default is *roughly* x2 production rate Config["ByproductModifier"] = byproductModifier = GetConfig("ByproductModifier", 1f); Config["ByproductPercent"] = byproductPercent = GetConfig("ByproductPercent", 50); Config["FuelUsageModifier"] = fuelUsageModifier = GetConfig("FuelUsageModifier", 1); Config["CookedModifier"] = cookedModifier = GetConfig("CookedModifier", 1f); Config["CookedPercent"] = cookedPercent = GetConfig("CookedPercent", 100); Config["OvercookMeat"] = overcookMeat = GetConfig("OvercookMeat", false); Config["UsePermissions"] = usePermissions = GetConfig("UsePermissions", false); // Remove old config entries Config.Remove("ChancePerConsumption"); Config.Remove("CharcoalChance"); Config.Remove("CharcoalChanceModifier"); Config.Remove("CharcoalProductionModifier"); Config.Remove("DontOvercookMeat"); Config.Remove("ProductionModifier"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["High Ping Kick (true/false)"] = highPingKick = GetConfig("High Ping Kick (true/false)", true); Config["Kick Notice Messages (true/false)"] = kickNotices = GetConfig("Kick Notice Messages (true/false)", true); Config["Repeat Checking (true/false)"] = repeatChecking = GetConfig("Repeat Checking (true/false)", true); Config["Warn Before Kicking (true/false)"] = warnBeforeKick = GetConfig("Warn Before Kicking (true/false)", true); // Settings Config["High Ping Limit (Milliseconds)"] = highPingLimit = GetConfig("High Ping Limit (Milliseconds)", 200); Config["Kick Grace Period (Seconds)"] = kickGracePeriod = GetConfig("Kick Grace Period (Seconds)", 30); // Cleanup Config.Remove("AdminExcluded"); Config.Remove("HighPingKick"); Config.Remove("KickNotices"); Config.Remove("PingLimit"); Config.Remove("RepeatCheck"); Config.Remove("WarnBeforeKick"); SaveConfig(); }
protected override void LoadDefaultConfig() { // Options Config["Inform On Attack (true/false)"] = informOnAttack = GetConfig("Inform On Attack (true/false)", true); Config["Show Name Prefix (true/false)"] = showNamePrefix = GetConfig("Show Name Prefix (true/false)", true); // Settings Config["Name Prefix (Default [God])"] = namePrefix = GetConfig("Name Prefix (Default [God])", "[God]"); //Config["Durability Boost (0 - 100, 0 to Disable)"] = durability = GetConfig("Durability Boost (0 - 100 Percent, 0 to Disable)", 0); // TODO: Finish Config["Time Limit (Seconds, 0 to Disable)"] = timeLimit = GetConfig("Time Limit (Seconds, 0 to Disable)", 0); // Cleanup Config.Remove("CanBeHurt"); Config.Remove("CanBeLooted"); Config.Remove("CanEarnXp"); Config.Remove("CanHurtPlayers"); Config.Remove("CanLootPlayers"); Config.Remove("InfiniteRun"); Config.Remove("InformOnAttack"); Config.Remove("PrefixEnabled"); Config.Remove("PrefixFormat"); SaveConfig(); }
protected override void LoadDefaultConfig() { Config["UsePermissions"] = usePermissions = GetConfig("UsePermissions", false); Config["OvercookMeat"] = overcookMeat = GetConfig("OvercookMeat", false); Config["ExpertModeEnabled"] = expertModeEnabled = GetConfig("ExpertModeEnabled", false); if (expertModeEnabled) { Config["ByproductModifier"] = byproductModifier = GetConfig("ByproductModifier", 1f); Config["ByproductPercent"] = byproductPercent = GetConfig("ByproductPercent", 50); Config["FuelUsageModifier"] = fuelUsageModifier = GetConfig("FuelUsageModifier", 1); Config["CookedModifier"] = cookedModifier = GetConfig("CookedModifier", 1f); Config["CookedPercent"] = cookedPercent = GetConfig("CookedPercent", 100); Config.Remove("CookInFurnaces"); Config.Remove("OvenMultipliers"); Config.Remove("CookTimes"); Config.Remove("AmountsOfBecome"); Config.Remove("CharcoalPercentLoss"); Config.Remove("CharcoalMultiplier"); Config.Remove("WoodFuelAmount"); } else { Config["CookInFurnaces"] = cookInFurnaces = GetConfig("CookInFurnaces", false); Config["OvenMultipliers"] = ovenMultipliers = GetConfig("OvenMultipliers", new Dictionary <string, object>()); var baseOvens = Resources.FindObjectsOfTypeAll <BaseOven>().Where(c => !c.isActiveAndEnabled && !(c is BaseFuelLightSource)).Cast <BaseEntity>().ToList(); foreach (var oven in baseOvens) { if (!ovenMultipliers.ContainsKey(oven.ShortPrefabName)) { ovenMultipliers.Add(oven.ShortPrefabName, 1.0f); } } Config["CookTimes"] = cookTimes = GetConfig("CookTimes", new Dictionary <string, object>()); foreach (var itemDef in ItemManager.GetItemDefinitions()) { ItemModCookable component = itemDef.GetComponent <ItemModCookable>(); if (component) { if (!overcookMeat && (component.name.Contains("cooked") || component.name.Contains("burned"))) { continue; } if (!cookTimes.ContainsKey(component.name.Replace(".item", ""))) { cookTimes.Add(component.name.Replace(".item", ""), component.cookTime); } } } Config["AmountsOfBecome"] = amountsOfBecome = GetConfig("AmountsOfBecome", new Dictionary <string, object>()); foreach (var itemDef in ItemManager.GetItemDefinitions()) { ItemModCookable component = itemDef.GetComponent <ItemModCookable>(); if (component) { if (!overcookMeat && (component.name.Contains("cooked") || component.name.Contains("burned"))) { continue; } if (!amountsOfBecome.ContainsKey(component.name.Replace(".item", ""))) { amountsOfBecome.Add(component.name.Replace(".item", ""), component.amountOfBecome); } } } Config["CharcoalPercentLoss"] = charcoalPercentLoss = GetConfig("CharcoalPercentLoss", 25); Config["CharcoalMultiplier"] = charcoalMultiplier = GetConfig("CharcoalMultiplier", 1); Config["WoodFuelAmount"] = woodFuelAmount = GetConfig("WoodFuelAmount", 10.0f); Config.Remove("ByproductModifier"); Config.Remove("ByproductPercent"); Config.Remove("FuelUsageModifier"); Config.Remove("CookedModifier"); Config.Remove("CookedPercent"); if (!overcookMeat) { foreach (var amount in amountsOfBecome.ToList()) { if (amount.Key.Contains("cooked") || amount.Key.Contains("burned")) { amountsOfBecome.Remove(amount.Key); } } foreach (var amount in cookTimes.ToList()) { if (amount.Key.Contains("cooked") || amount.Key.Contains("burned")) { cookTimes.Remove(amount.Key); } } } } SaveConfig(); }
/// <summary> /// Checks whether the configuration file contains unused keys and removes them. /// </summary> void CleanupConfig() { List <string[]> paths = new List <string[]>(); // iterate over the current configuration file to find all existing paths IEnumerator enumerator = Config.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair <string, object> pair = (KeyValuePair <string, object>)enumerator.Current; if (pair.Value.GetType().IsGenericType&& pair.Value.GetType().GetGenericTypeDefinition() == typeof(Dictionary <,>) && ((IDictionary)pair.Value).Count != 0) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); foreach (DictionaryEntry entry in (IDictionary)pair.Value) { dictionary.Add((string)entry.Key, entry.Value); } foreach (KeyValuePair <string, object> pair2 in dictionary) { if (pair2.Value.GetType().IsGenericType&& pair2.Value.GetType().GetGenericTypeDefinition() == typeof(Dictionary <,>) && ((IDictionary)pair.Value).Count != 0) { Dictionary <string, object> dictionary2 = new Dictionary <string, object>(); foreach (DictionaryEntry entry in (IDictionary)pair2.Value) { dictionary2.Add((string)entry.Key, entry.Value); } foreach (KeyValuePair <string, object> pair3 in dictionary2) { if (char.IsDigit(pair3.Key[0]) && pair3.Key[1].Equals('.') && char.IsDigit(pair3.Key[2]) && pair3.Key[3].Equals('.') && char.IsDigit(pair3.Key[4])) { paths.Add(new string[3] { pair.Key, pair2.Key, pair3.Key }); } else { paths.Add(new string[2] { pair.Key, pair2.Key }); break; } } } else { paths.Add(new string[2] { pair.Key, pair2.Key }); } } } else { paths.Add(new string[1] { pair.Key }); } } } finally { ((IDisposable)enumerator).Dispose(); } // iterate over the found paths and determine whether they are part of the default configuration foreach (string[] path in paths) { int index = -1; foreach (ConfigValue value in DefaultConfig.values.Values) { if (path.Length != value.path.Length) { continue; } for (int j = 0; j < path.Length; j++) { if (path[j].Equals(value.path[j])) { index = j > index ? j : index; } else { break; } } } // if a path is not part of the default configuration remove it if (index < path.Length - 1) { if (index == -1) { Config.Remove(path[index + 1]); } else { string[] strArray = new string[index + 1]; for (int j = 0; j < strArray.Length; j++) { strArray[j] = path[j]; } ((Dictionary <string, object>)Config.Get(strArray)).Remove(path[index + 1]); } } } }