How i get the 10 players with highers values in config?

Discussion in 'Plugin Development' started by Gonmarte, Aug 25, 2015.

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

    Gonmarte

    Hi guys im making a plugin and i want to make a command that shows the top dragon kills. Every players in my server are in config and shows to each one the number of dragon that they killed.
    I just dont know where i start.. can u help me how to make 1? thank you
    If u need my code tell-me that ill add it!
     
  2. Offline

    MCMatters

    for loop get player name of highest score.
     
  3. Offline

    Gonmarte

    And how i do that?
     
  4. Offline

    Zombie_Striker

    @Gonmarte
    What parts confusing you, the for loop or getting the highest score?

    Show you with examples, no. We will tell you how to go about doing though.
     
  5. Offline

    Gonmarte

    @Zombie_Striker So can u pls teach me? Im not saying to sponefeed im just saying to help me get though this problem and help me make a lead :/ I dont know how i get the 10 players with the highest value in the config ...
     
  6. Offline

    Zombie_Striker

    @Gonmarte
    1. Create a map where the keys are Integers, and the Values or UUID's
    2. Create a for lop to loop through all the players
    3. Get the players score from the config.
    4. Create a loop for integers, starting at 1 and going upto 10
    5. If the map does not have that values saved (e.g. !map.contains(int)) or if the value it returns is less than the score (map.get(int) < score) do the following
    6. Create a backwards loop which will set each key up down by one (map.put(number-1,map.get(number)))
    7. After setting all the values down by one, put your score into the map with the and assign the key to be that of the ranking (the now open slot in the map)
    8. One this is done for all players, the player with the highest score will have a key of 1,the player with second highest score will be 2 ect.
    This is the process of creating a map contain the players with the highest scores. This is as simple as I can explain it without posting code.
     
    Gonmarte likes this.
  7. Offline

    Gonmarte

    @Zombie_Striker Didnt understand at all .......... Im just going to forget this....... Im not good enoough to make this but thank you anyway.
     
  8. Offline

    rbrick

    Zombie_Striker likes this.
  9. Offline

    Gonmarte

    @rbrick Wow Why u even care? If u arent here to help just dont post threads..
     
  10. Offline

    Zombie_Striker

    @Gonmarte
    No, he's right. Look at my signature.
     
  11. Offline

    Gonmarte

  12. Offline

    Zombie_Striker

    @Gonmarte
    If you went up to my first post, you would see this:
    ---Learn Java before making plugins----
    MyPlugin.....


    If you understood the way Hashmaps/for loops work, you should get the idea of how to make this method, or at the least understand the steps I gave.
     
  13. Offline

    rbrick

    @Gonmarte
    You said
    this (open)

    If you want to be "good enough", you need to learn and understand the language (Java). I was giving you legitimate advice as @Zombie_Striker said. If you need help learning the language, you can take a look at the Java tutorials or thenewboston
     
    OhYes likes this.
  14. for(String randomPlayersUUID : config#getConfigurationSection("users").getKeys(false)) {
    String pathToDragonKills = "users." + .randomPlayersUUID + ".dragon-kills"
    }
    something like that

    skrub
     
  15. Offline

    Gonmarte

    @TheGamesHawk2001 u are not helping me... I hope u understand that post a random code wont help, if u want to sponefeed at least u need to explain what u did.
     
  16. Offline

    ProSl3nderMan

    Alright, for-loop through your list of players and store the value into a hashmap. Then sort it then make another for-loop that goes counts to the top 10 and break the loop. After that, you just need to send the value. I believe that's how you could do it O-e. If you don't know how to for-loop or use hashmaps, please search it up and watch a few tutorials on it.
     
  17. Offline

    Zombie_Striker

    @ProSl3nderMan
    That is not very descriptive and it does not have all the needed steps (also, you shouldn't loop all the way to ten for a top ten list, loop till the score of the the value is greater than the score you are trying to put in)

    I don't think anyone can explain it better than what I did above without posting code
     
  18. Offline

    ProSl3nderMan

    Ah yes, I was wrong or I didn't clarify what I meant hehe :p
     
  19. @Gonmarte I'm surprised anyone's helping you with your attitude.
     
  20. Offline

    Gonmarte

  21. Offline

    Gonmarte

    @MrBlackIsBack What?

    @MrBlackIsBack Thats what im trying to make -. i didnt know how to make and i asked. :c That websites shows all the things that we cando with a hashmap, and how to use a hashmap.. all the things about hashmap?

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
     
    Last edited by a moderator: Aug 27, 2015
  22. It tells you everything you need to know about java :)
     
  23. Offline

    Gonmarte

    ik, thank you for the help guys.
    Dont need to reply more thread!
    End of The Thread =)
    If i need any help with this ill ask u after i learn more about haspmaps =)
     
  24. Offline

    au2001

    @Gonmarte End of The Thread = mark this as filled :)
     
Thread Status:
Not open for further replies.

Share This Page