Solved Need Help with YML

Discussion in 'Spigot Plugin Development' started by MrGamingLion66, Apr 27, 2017.

  1. Hey everyone, I'm working with some YML files to store data about certain maps and to access this data I made a yml for "registering" a map so the data can be used. However, a value that should be returning the number of registered maps returns zero.

    Here is the method:
    Code (Text):
    public int getTotalArenas()
    {
        Bukkit.broadcastMessage("Number of Arenas: " + tagConfiguration.getInt("Number of Arenas") + "");
        return tagConfiguration.getInt("Number of Arenas");
    }
    Here is the line from the yml:
    Number of Arenas:1
     
  2. You should not use spaces but rather a - with no upper case for YAML configuration syntax.

    Code (Text):
    number-of-arenas: 1
     
    • Agree Agree x 4
  3. @Synapz
    Thanks, I've never needed more that one word before so I didn't know.
     
    • Friendly Friendly x 1
  4. You can uses spaces in YAML keys (even GriefPrevention uses spaces in some of it's keys). The problem is you don't have a space after the colon, so it's not registering as a key: value pair in the configuration map.
     
  5. @BillyGalbreath @Synapz
    Hey, so I'm having another integer that is returning 0 in a new config.

    Code:
    Code (Text):
    public int getMapPack()
    {
        return arenaConfiguration.getInt("map-pack");
    }
    Line in config:
    map-pack: 1
     
  6. Never mind everyone, as it turns out I wasn't getting the correct config file because of another error in the code.