Solved [YAML HELP] Checking if section is empty

Discussion in 'Plugin Development' started by Joshuaknight1998, Jul 29, 2015.

Thread Status:
Not open for further replies.
  1. Hey, I'm coding a plugin that has a feature that checks if an NPC is a "merchant", then grabs the trades via yaml file. First, an example config.

    Code:
    npcs:
      npc1:
        name: "test"
        isMerchant: false
        trades:
      npc2:
        name: "test2"
        isMerchant: true
        trades:
          trade1:
            - buyitemstack1
            - buyitemstack2
            - sellitemstack
    So I check if the NPC is a merchant, then if they are, I check their trades. But first, I'm going to have to check if the "trades" list is empty. Is there any way of doing this? Thanks!
     
  2. Offline

    Eos

    This should do the trick.
    Code:
                if ( getConfig().get("trades") == null ){
                    //proceed
                }
     
  3. @Eos You seem pretty credible & I don't have time to test it tonight, but that seems like it'd be the solution. Thanks a bunch! Solved.
     
Thread Status:
Not open for further replies.

Share This Page