Creating a toplist out of a YML file?

Discussion in 'Plugin Development' started by Zeryther, Feb 7, 2014.

Thread Status:
Not open for further replies.
  1. Hey Bukkit Forums!

    I have a problem: I want to create a /top command out of a YML File. My constuction is like this:

    Code:
    Player:
        Zeryther:
            Points: 100
    At the moment it's impossible for me to change to a MySQL database. Anybody have a code snippet or something like that for me?

    Regards,
    ~ Zeryther
     
  2. Offline

    EnderTroll68

    I do actually! Would you like to be spoon fed the code or just me tell you how to do it?

    Take a look at this post:
    http://stackoverflow.com/a/780576/3191662

    Also here is an example code to get you to the same point where they started:
    Code:java
    1. Map<String, Integer> top = new HashMap<String, Integer>();
    2. List<String> players = yml.getStringList("Player");
    3. for (int i = 0; i < players.size(); i++) {
    4. top.put(players.get(i), yml.getInt("Player." + players.get(i)));
    5. }


    Zeryther

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  3. I still don't really understand how to implement this to my code..
     
  4. Zeryther
    This is a rather complicated thing to do. I found this resource, which gives a good demonstration of how to go about doing it :) I have been planning on making a simple resource in the Resources section dealing with this, but I just never got around to it :(

    http://www.mkyong.com/java/how-to-sort-a-map-in-java/
     
Thread Status:
Not open for further replies.

Share This Page