Example #1
0
        private bool MaybeUpdateConfig(SerializableConfiguration config)
        {
            var currentWithDefaults = config.ToDictionary();
            var currentRaw          = Config.ToDictionary(x => x.Key, x => x.Value);

            return(MaybeUpdateConfigDict(currentWithDefaults, currentRaw));
        }
Example #2
0
        protected override void LoadConfig()
        {
            base.LoadConfig();

            try
            {
                _config = Config.ReadObject <PluginConfig>();

                if (_config == null)
                {
                    throw new JsonException();
                }

                if (!_config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys))
                {
                    PrintWarning("Config was updated");

                    SaveConfig();
                }
            }
            catch
            {
                PrintWarning("Invalid config, default config has been loaded.");

                LoadDefaultConfig();
            }
        }
Example #3
0
        protected override void LoadConfig()
        {
            base.LoadConfig();

            try
            {
                _config = Config.ReadObject <PluginConfig>();

                if (_config == null)
                {
                    throw new JsonException();
                }

                if (!_config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys))
                {
                    PrintWarning($"PluginConfig file {Name}.json updated.");

                    SaveConfig();
                }
            }
            catch
            {
                LoadDefaultConfig();

                PrintError("Config file contains an error and has been replaced with the default file.");
            }
        }
Example #4
0
        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject <Configuration>();
                if (config == null)
                {
                    throw new JsonException();
                }

                try
                {
                    foreach (string eachSirenFile in Interface.Oxide.DataFileSystem.GetFiles(DATAPATH_SIRENS, "*.json"))
                    {
                        string theFilename = eachSirenFile.Basename(".json");
                        try
                        {
                            Siren theSiren = Interface.Oxide.DataFileSystem.ReadObject <Siren>(DATAPATH_SIRENS + theFilename);
                            SirenDictionary.Add(theSiren.Name, theSiren);
                        }
                        catch
                        {
                            PrintWarning($"Siren file {theFilename}.json is invalid; ignoring");
                        }
                    }
                }
                catch
                {
                }
                Puts("Loaded sirens: " + string.Join(", ", SirenDictionary.Keys));

                if (SirenDictionary.IsEmpty())
                {
                    PrintWarning("Configuration appears to be missing sirens; using defaults");
                    SirenDictionary.Add(SIREN_DEFAULT.Name, SIREN_DEFAULT);
                    SirenDictionary.Add(SIREN_SILENT.Name, SIREN_SILENT);
                    SaveConfig();
                }

                if (!config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys))
                {
                    PrintWarning("Configuration appears to be outdated; updating and saving");
                    SaveConfig();
                }
            }
            catch
            {
                PrintWarning($"Configuration file {Name}.json is invalid; using defaults");
                LoadDefaultConfig();
            }
        }
Example #5
0
        protected override void LoadConfig()
        {
            base.LoadConfig();
            try {
                config = Config.ReadObject <Configuration>();
                if (config == null)
                {
                    throw new JsonException();
                }

                if (!config.ToDictionary().Keys.SequenceEqual(Config.ToDictionary(x => x.Key, x => x.Value).Keys))
                {
                    PrintToConsole("Configuration appears to be outdated; updating and saving");
                    SaveConfig();
                }
            } catch {
                PrintToConsole($"Configuration file {Name}.json is invalid; using defaults");
                LoadDefaultConfig();
            }
        }