Solved Quick Question !IMPORTANT!

Discussion in 'Plugin Development' started by FireBreath14, Sep 6, 2013.

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

    FireBreath14

    So I'm writing a plugin and I am utilizing the config.yml to store players' names. What I want to know is if I can skip a level? Heres an example config:


    Code:
    players:
      uncool:
        justinbieber911: {}
      cool:
        robertdowneyjr305: {}

    So there is a created section for justinbieber911 under "uncool" (lol) and one for robertdowneyjr305 under "cool". Well say I didn't know that - is this code possible?

    Code:
    if(plugin.getConfig().contains("players.*.robertdowneyjr305")){
      //do whatever
    }else{
      //do whatever
    }
    So i use an asterisks to skip the middle level (cool and uncool) and just try to find where robertdowneyjr305 is. Is this at all possible or am I thinking too hard?

    Thanks in advance answer soon!
     
  2. Offline

    SxeLlama

    FireBreath14
    You could just check if getConfig().contains(<insert whatever name here>)
     
  3. Offline

    FireBreath14

    Or is there a way to get the level above a player? Could I see if they are cool or uncool without knowing first?
     
  4. Offline

    CubieX

    FireBreath14
    I think it would be better then to structure your config differnt.
    Example:
    Code:
    players:
      player1:
        status: cool
      player2:
        status: uncool
    This way you can check the status of a player like this:
    Code:
    if(getConfig().getString("players." + playerName + ".status").equals("cool"))
    {
      // do cool stuff
    }
    else
    {
      // do uncool stuff
    }
     
  5. Offline

    FireBreath14

    I think i figured it out - thanks everyone
     
Thread Status:
Not open for further replies.

Share This Page