1. What I can only assume is a bug is best described with an example plugin:
    Code:
    namespace Oxide.Plugins
    {
        class BugReproduction : RustPlugin
        {
            protected override void LoadDefaultConfig()
            {
                Config["firstKey", "secondKey"] = false;
                SaveConfig();
            }        void OnServerInitialized()
            {
                object obj = Config.Get("firstKey", "secondKey", "thirdKey");
            }
        }
    }
    Lets go through this plugin function by function!
    The LoadDefaultConfig() function is simple enough.
    It just creates a configuration file with the name BugReproduction.json.
    The content of said json file is the following:
    Code:
    {
      "firstKey": {
        "secondKey": false
      }
    }
    The OnServerInitialized() function then tries to get a value with a path that does not exist!
    Since the path does not exist the value returned should be null but what happens instead is that we'll get an InvalidCastException:
    [​IMG]

    The same thing happens if we do:
    Code:
    Config.Set("firstKey", "secondKey", "thirdKey", false);
    Surely this is not intended. The value returned should just be null, right?
     
    Last edited by a moderator: Mar 10, 2016
  2. Calytic

    Calytic Community Admin Community Mod

    This is happening because "secondKey" is not a Dictionary<string, object>.
     
  3. My only concern is whether this will be fixed. In the case described above Config.Get("firstKey", "secondKey", "thirdKey") should just return null and Config.Set("firstKey", "secondKey", "thirdKey", false) should overwrite the existing path so the new configuration file will look like this:
    Code:
    {
      "firstKey": {
        "secondKey": {
          "thirdKey": false
        }
      }
    }
    @Wulf is this something that will get fixed at some point?
     
  4. Calytic

    Calytic Community Admin Community Mod

    My 2 cents, I agree with you that the configuration handler should be more fault-tolerant.
     
  5. Bump!

    @Wulf is this an issue you guys are aware off/are going to fix?
     
  6. Wulf

    Wulf Community Admin

    It should be fixed with the latest commit and in the next snapshots.
     
  7. Great news! That's the only thing stopping my KillFeed Config Clean-UP implementation from working properly in all cases, afaik! Thank you. :)
     
  8. Wulf

    Wulf Community Admin

    Thank @bawNg, I just bugged him about it. ;)