BML/YAML help!

Discussion in 'Plugin Development' started by NeoSilky, Oct 1, 2011.

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

    NeoSilky

    Hi, so i'm trying to make a really cool plugin, but i'm having trouble with some of the config and yml settings, can someone teamviewer me, or skype to me help... pleaseeee :D :D :D :D :D
     
  2. Wait... YOU need help for configuration? I just wanted to PM you cause of a config question. :(
    Anyway, I ask it here now: You made a plugin not long ago, I just can't remember which one, where you had a config like this:
    Code:
    foo:
      a: blub
      b: maunz
    And my question is: How do you access a and b from foo?
     
  3. Offline

    NeoSilky

    That's kinda what i want to know :') i want it to happen so when a player types a command, it adds their entry into the .yml i have setup and then adds several entries under that one like your one you just gave me like:
    Code:
    NeoSilky:
      somerandom: true
      random: maunz
    I want to know how to do it :')
     
  4. So... we're trying to figure out the same things at the same time? Creepy... :D
    But I want to know how to (easily) read such a configuration, too. ;)
     
  5. Offline

    NeoSilky

    I'm just going to shout.

    HELPPPPPPPP!

    How did you make your code do that anyway, pm me? :)
     
  6. Offline

    Kanlaki101

    V10lator likes this.
  7. Offline

    NeoSilky

  8. @Kanlaki101[/COLOR]: Okay, but what do I get if I read out the configuration node "player" (in your example)? Because I need this more dynamic but can't test for myself right now. :(
     
  9. Offline

    Kanlaki101

    Code:
    playerIsDamaged = CONFIG.getBoolean("player.damaged", true);
    
    if (playerIsDamaged) { // if player.damaged is true
    // do something
    } else {
    // do something if false
    }
    Should work.
    Just typed it real fast.
     
  10. Didn't answer my question (what CONFIG.getString("player") would return) but anyway, I got the dynamic I needed with some getKeys() magic :D
     
  11. Offline

    iffa

    config.getString("player") would return the value of the player-key in the config?
     
  12. And what is the value if it's like in that example:
    Code:
    player:
      somerandom: true
      random: maunz
     
  13. Offline

    NeoSilky

    What i want to know is how do you make a new
    Code:
    player:
      somerandom: true
      random: maunz
    where 'player' is the name of the player that did something?
     
  14. Wow, just realized that my code does this but... wrong... let me check... ;)
     
    NeoSilky likes this.
  15. Offline

    Ahniolator

    @V10lator
    This should work for that situation:

    Code:java
    1. Player player = example.getPlayer();
    2. exampleBoolean = config.getBoolean(player.getName() + ".somerandom", true);
    3. exampleString = config.getString(player.getName() + ".random", null);


    EDIT: Setting the values would be very similar:
    Code:java
    1. Player player = example.getPlayer();
    2. config.setProperty(player.getName() + ".somerandom", exampleBooleanValueHere);
    3. config.setProperty(player.getName() + ".random", exampleStringHere);
     
  16. @Ahniolator: True and exactly what my code does right now (well, not with player names...) just had a little error in it. ;)
     
  17. Offline

    Ahniolator

    I probably would've set the player name as a string instead of calling the getName method twice too, but hey, it's an example ;)

    Offtopic edit: Our names sound eerily similar :p
     
    NeoSilky likes this.
Thread Status:
Not open for further replies.

Share This Page