Getting a sub-section in a config

Discussion in 'Plugin Development' started by kampai, Jul 14, 2016.

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

    kampai

    What I'm trying to do is have a list then under that list, a sub-list which I know isn't possible. What would be an alternate to this? My config looks something like this
    Code:
    kits:
    -name
    -name2
    -name3
    I'd like it to look like this
    Code:
    kits:
    -name
         -lore
    -name2
         -lore
    -name3
          -lore
    EDIT: How do I get the name?
     
    Last edited: Jul 14, 2016
  2. Offline

    ipodtouch0218

    getStringList("kits.name");
     
  3. Why not just

    Code:
    kits: 
      kitName:
        - Stuff
      kit2Name:
        - More stuff
     
  4. Offline

    kampai

    @bwfcwalshy
    I tried but then some kitnames might have the same lists, and then if they do they dont print out. Like this
    Code:
    kits:
      kitname1:
              -lol
       kitname2:
               -lol
    But kitname2 would have the list "-lol" because kitname1 already has it
     
  5. Offline

    Lordloss

    What? Why should the entrys be interested in what is in their list? It makes no difference if you have the same list multiple times in different places in your config, you can still access them by getList("kitnameXY")
     
  6. Offline

    kampai

    @Lordloss
    Code:
    kits:
      kitone: &id001
      - KIT_ONE
      - KIT_TWO
      - KIT_THREE
      kittwo: *id001
      kitthree: *id001
    Code:
    List<String> pTemp = Arrays.asList("KIT_ONE","KIT_TWO","KIT_THREE");
    
    playerData.set("kits.kitone", pTemp);
    playerData.set("kits.kittwo", pTemp);
    playerData.set("kits.kitthree", pTemp);
     
  7. Yes, they look like that, but thats just how yaml saves them. What you can do is make a new file for each of the lists, then the config files wont look like that.
     
    I Al Istannen likes this.
  8. Offline

    Lordloss

    That makes no sense. What happens if you get kit two or three?
     
  9. Offline

    kampai

    @Lordloss
    it checks if they have a config (using individual player yml files) if they have a config and if they dont it sets their data to that but instead of actually printing the other lists it just does that
     
  10. Offline

    Lordloss

    I mean what you get if you do something like getList("kits.kittwo"). It would be much easier if you give us your code.
     
  11. Offline

    kampai

    @Lordloss
    The whole config class? and it prints the list
     
  12. Offline

    I Al Istannen

    @kampai
    As it was already said, this is just how YAML stores the data. It would be useless to just write the same list again. You can save quite a lot of space by replacing duplicate entries, which is why Bukkits YAML does it. Not much for you to do there :/

    But why would you even need it?
     
  13. Offline

    kampai

    @I Al Istannen
    Okay I see but now how would i get the "kitname1" now?
     
  14. @kampai The same way you always do, I'm not seeing the issue here. When you get a duplicate list I'm not sure what it returns but I assume the original path or the list. What is the issue here?
     
  15. Offline

    kampai

    @bwfcwalshy
    I'm not trying to get the list, I'm trying to get the "kitname" sections
     
  16. Offline

    Lordloss

    :rolleyes: Then why you do you confuse everybody with list stuf.. config.getConfigurationSection
     
Thread Status:
Not open for further replies.

Share This Page