How read this config?

Discussion in 'Plugin Development' started by JoeyDevs, Jul 9, 2014.

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

    JoeyDevs

    Hey All,

    I want to make something with a config but I don know how.
    This is what i want as Config:
    Code:
    amountlist:
      1:
        name: 'blabla'
        message: 'blabla'
        items:
          - 102
      
    I want a config like that but the user need to create the own amount list.
    Nothing is pre defined. But how i can read every single list ( like: 1 ) and use the below given strings and item list.


    Question: How I can read and make a config like above?
     
  2. Offline

    MCMastery

    JoeyDevs Google it. And what code have you tried
     
  3. Offline

    JoeyDevs

    If I don't know how to do i think i have tried nothing -_- In the past i only worked with single string and stuff in a config but now i need this but i still cant find it
     
  4. Offline

    Necrodoom

  5. Offline

    dsouzamatt

  6. Offline

    JoeyDevs

    Necrodoom Thanks

    dsouzamatt Need posts? You will post again the same link only 'hidden' with text hyperlink.. Sorry it was useless it was already posted!


    ==================

    But
    Oke I find it how to do that but
    Code:
    Paths
     
    The Configuration API uses Paths to form a unique key to value pairs. A path is the set of keys used to associate a value. Each level is separated by the path separator, which is by default the '.' (period). For example the following YAML file has the following set of paths.
     
        key: value
        one:
          two: value
          three:
            - values
            - values
            - values
          four:
            five: value
          *:
            six: value
            seven: value
     
        key
        one
        one.two
        one.three
        one.four
        one.four.five
        one.*
        one.*.six
        one.*.seven 
    But now still the question items naver has the same Item DB, And also i said that the 1 can be diffrent so amountlist.1.name should not work cuz the user can also make amountlist.helppack.name , So how i do read all the created things?

    Code:
    amountlist:
      1:
        name: 'blabla'
        message: 'blabla'
        items:
          - 102
      

    What i need to do?
    Code:java
    1. foreach(getConfig().getString("amountlist.*") as blabla) {
    2. getServer().broadcastMessage(blabla);
    3. }


    Or something like that
     
  7. Offline

    Necrodoom

    JoeyDevs you do know we posted at around the same time, yes? Blaming dsouzamatt for post hoarding because his post wasn't helpful for you just makes me want to not help you at all.
     
    dsouzamatt likes this.
  8. Offline

    dsouzamatt

    Thank you, Necrodoom.

    JoeyDevs, if you have been on these forums for any amount of time you will know that often one person will post a reply in a thread while another is typing theirs. No, I did not see the other link to the same page or I wouldn't have posted it again; go back and check the times, my message went up barely a minute after Necrodoom's.

    Please take a moment to think before making these sorts of comments in future.
     
    ZodiacTheories likes this.
  9. Offline

    JoeyDevs

    Or you just go back to Topic and not off topic. And I saw it but i can also say Check out times.

    Necrodoom, Today at 1:44 PM

    dsouzamatt, 5 minutes ago


    he said kind of the same what you are saying now and you just do it again. But anyways This is off topic so.


    Is it good what i have posted before
     
  10. JoeyDevs People do still do that, respond in defense of themselves in order to confirm the truth in what has already been said. :)
     
    dsouzamatt likes this.
  11. Offline

    JoeyDevs

    Hey guys,

    I made some progress after trying some stuff and now Im stuck.

    What I want now:
    {=} When the player has ** Amount of kills he will get a message an the given rewards.

    My Code:
    Code:java
    1. public void onEnable() {
    2. getServer().getConsoleSender().sendMessage(Prefix + ChatColor.GREEN + "Enabled");
    3. if(!F_Config.exists()){
    4. try {
    5. Config.createSection("Killstreaks");
    6. Config.createSection("Killstreaks.5");
    7. Config.set("Killstreaks.5.Message", "&6%player%&b reached a killing spree of &l&c5");
    8. Config.set("Killstreaks.5.Rewards", Rewards);
    9. Config.save(F_Config);
    10. } catch (IOException e) {
    11. getServer().getConsoleSender().sendMessage(Prefix + ChatColor.DARK_AQUA + "Saving of " + ChatColor.GOLD + "config.yml" + ChatColor.RED + "Failed");
    12. }
    13. }
    14. for ( String keys1 : Config.getConfigurationSection(MainSection).getKeys(false) ) {
    15. for ( String keys2 : Config.getConfigurationSection(MainSection + "." + keys1).getKeys(false) ) {
    16. }
    17. }
    18. }



    How can I sace the results or store idk that i can in a other event do this:
    Code:java
    1. if ( PlayerKills == KillStreakKills ) {
    2. // Send the message
    3. // Give the items
    4. }


    Created config for now:
    Code:
    Killstreaks:
      '5':
        Message: '&6%player%&b reached a killing spree of &l&c5'
        Rewards:
        - ''
      '10':
        Message: '&6%player%&b reached a killing spree of &l&c10'
        Rewards:
        - ''
     
  12. Offline

    JoeyDevs

    Somebody?
     
  13. Offline

    UaVxChallenge

    JoeyDevs
    Are you putting it the main class?
     
  14. Offline

    JoeyDevs

    What in the main class?


    The code i showed in the post before is in the mainclass
     
  15. Offline

    UaVxChallenge

    Are you going to be calling it in the main class or in a different class?
     
  16. Offline

    JoeyDevs

    Ìn the main class
     
Thread Status:
Not open for further replies.

Share This Page