Solved ConfigurationSection.get(String path) returning null instead of MemorySection

Discussion in 'Plugin Development' started by MrFigg, Sep 18, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    MrFigg

    Hey, so I'm having a problem with ConfigurationSection that I can't quite figure out. I have a config.yml with this in it;
    Code:
    teams:
      teams1:
        name: Red Team
        color: Red
        spawns: {}
    test:
      team:
        name: Blue Team
        color: Blue
        spawns: {}
    After I load it with YamlConfiguration.loadConfiguration() and cast it, I end up with a ConfigurationSection config. When I try config.get("test.team") I get a MemorySection back as I expected, but when I try config.get("teams.teams1") it returns null. And yet both config.isSet("test.team") and config.isSet("teams.teams1") returns true. The only real difference I see is that the teams.teams1 has an numeral in the path, but I really didn't think that would be a problem. Just seems stupid for numerals to not be supported. And though I've never used them myself before I could have sworn I've seen them used in other plugins.

    Could someone explain what is going on to me? And if I'm not doing something wrong and it just doesn't work, does anyone know an easy way around it? I need to add a numerical id to each team that's easy to read. I thought of converting numerals to text, i.e. teamsone/teamstwo, but I want to use the same approach with other lists that don't have a max cap, and that would get annoying once you get higher up.

    Oh, and if no one is able to reproduce this, than sorry. I'm still having trouble believing I'm having this error. Please tell me and I'll go back and look through my code some more. Though there aren't many more debug checks I could put before this.

    Edit:
    Fixed it. This is an overly simplified explanation for what was going on that turned out be wrong. The real scenario involved nested ConfigurationSections and I was accidentally getting a parent ConfigurationSection instead of the one I wanted. Please ignore this post. (I feel stupid.)
     
Thread Status:
Not open for further replies.

Share This Page