Solved Config keys

Discussion in 'Plugin Help/Development/Requests' started by 2008Choco, Jun 19, 2015.

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

    2008Choco

    I googled and browsed the forums but couldn't find the simplistic answer I wanted :p

    Basically, I have a config that looks like this:
    Code:
    Messages:
        NoRemains: 'Unfortunately, you have not salvaged any remains'
        BowRemains: 'You have salvaged some items from your bow'
        SwordRemains: 'You have salvaged some items from your sword'
        PickaxeRemains: 'You have salvaged some items from your pickaxe'
        AxeRemains: 'You have salvaged some items from your axe'
        ShovelRemains: 'You have salvaged some items from your shovel'
        HoeRemains: 'You have salvaged some items from your hoe'
        HelmetRemains: 'You have salvaged some items from your helmet'
        ChestplateRemains: 'You have salvaged some items from your chestplate'
        LeggingsRemains: 'You have salvaged some items from your Leggings'
        BootsRemains: 'You have salvaged some items from your Boots'
        ShearsRemains: 'You have salvaged some items from your shears'
        FishingRodRemains: 'You have salvaged some items from your fishing rod'
        FlintAndSteelRemains: 'You have salvaged some items from your flint and steel'
    My goal is to get those string values when I need them. I have tried many things such as,
    Code:
    getConfig().getConfigurationSection("Messages").getString("NoRemains");
    Code:
    getConfig().getString("Messages.NoRemains")
    but it just returns a NullPointerException. I'm clearly doing something wrong :p Could someone explain to me how to get a specific value using Configuration Keys? I've never gotten around to figuring this out before
     
  2. Offline

    raymart23

    @2008Choco first at your main class you need
    Code:
    saveDefaultConfig();
    second use this
    Code:
    getConfig().getString("Messages.NoRemains");
    and at config you must kindly looks like this
    Code:
    Messages:
    // two spaces
      NoPermission: //string
     
  3. Offline

    2008Choco

    @raymart23 Thank you very much, but I am going to face palm. The first time I attempted this would have worked... but I brain farted and forgot to actually generate the configuration file in the first place.

    Yes... I was that stupid.

    Lol thanks for the help anyways, man. I had also put 4 spaces in my config so that would have hurt it was well
     
  4. Offline

    raymart23

Thread Status:
Not open for further replies.

Share This Page