Solved Config Help

Discussion in 'Plugin Development' started by Kiwanga, Oct 23, 2015.

Thread Status:
Not open for further replies.
  1. How to get Path....
    If i have an Config like this:
    http://hastebin.com/alofesovuc.rb
    and i want to know the path to Kiwanga... here ReMo.Kiwanga but i have just Kiwanga how do i get the "ReMo"?
    Thanks for your support :D

    ~Kiwanga
     
  2. Offline

    WHQ

  3. Offline

    Mrs. bwfctower

    You could iterate through the keys and check if contains kongwa, but you should probably think about redoing how you are storing information.
     
    Kiwanga likes this.
  4. Because im developing an Clan-System and i have to get Clan, which contains Kiwanga or UUIDs
     
  5. @Kiwanga So you have a value and not the key? Why are you storing so you don't know the key but the value? Can you please show how you're storing this.
     
    Kiwanga likes this.
  6. Offline

    Mrs. bwfctower

    You could store everything twice, for ease of lookup, so you would have a key with the UUID which has the clan, and a key with the clan that has the list of UUIDs.

    e.g. http://hastebin.com/gehekekasa.xml

    @bwfcwalshy There is a hastebin link showing how it's stored in the OP.
     
    Kiwanga likes this.
  7. @Mrs. bwfctower
    but then i have to save it 2 times... 1time for the clan and 1time for the players who has a clan.. but i want to save it just 1time xD
     
  8. Offline

    Mrs. bwfctower

    Then you lose time trying to find the clan from the UUID.
     
    Kiwanga likes this.
  9. Offline

    CoolDude53

    @Kiwanga The most efficient way to do this would be to have two saves, one with UUIDs associated with clans and one with clans associated with the member UUIDs, as recommended by the people above. The other way to do this would be to get the configuration section (i.e. the clan) or loop through all the configuration sections and use the MemorySection#getKeys() method to look for the UUID of the player you are checking. The latter would be vastly inefficient if run on a large scale.

    If you want to limit it to one file, then you can create a yaml with two sections: clans and players. Within the clans section, you would have each clan associated with their respective members, and within the players sections, you would have the player's UUID associated with his/her clan. If the player's UUID is not in the players section, then that player is not in a clan.

    Hopefully this helps you understand how to structure files and how you can use them for your purpose.
     
    Kiwanga likes this.
  10. Ok Thank you all but now im doing 1Config with 2Sections. 1Section for the Clans and 1Section for the Players, who have a clan.... But now i get errors, when i try to create my ocnfig... first i got an IOException but then i googled much and updated my code and now i get a NullPoinetException maybe you can help...
    My code:
    http://hastebin.com/xatedupido.coffee
    And i get the Null at this line:
    if (Main.getInstance().getDataFolder().exists()) {

    Hope you can help :D
    ~Kiwanga
     
  11. Offline

    Mrs. bwfctower

  12. now i dont get the nullpointer anymore but it still doesnt create my config xD .... still need help
     
  13. Offline

    Lolmewn

    Write it in OOP style and I'll see what you're doing wrong (e.g. remove all those hideous statics).
     
    Kiwanga likes this.
  14. @Kiwanga You don't need any of that :) Just saveDefaultConfig();
     
    Kiwanga likes this.
  15. Thank you all i got it :D
     
Thread Status:
Not open for further replies.

Share This Page