config.yml largest value

Discussion in 'Spigot Plugin Development' started by MaxKrissigo, May 14, 2016.

  1. I'm trying to create a leaderboard, and am wondering how I would go about collecting the player with most kills out of my config.yml. This the format I currently have:

    Code (Text):
        Kills: 1
        Deaths: 3
        Rank: REC
        CurrentKillStreak: 0
        BestKillStreak: 1
        Kills: 3
        Deaths: 1
        Rank: REC
        CurrentKillStreak: 1
        BestKillStreak: 2
  2. Are you creating objects with that data? If so you can implement a Comparable that compares the objects you have.
    If not you will have to save the uuid and the kills to a map or something (or create a object with it) and then sorting it.
    EDIT: And if you are going to store lots of data maybe you are better off sticking with a database instead of yaml, mysql provides a way to select rows sorting it depending on a value
    #2 Jamezrin, May 14, 2016
    Last edited: May 14, 2016
  3. How would I go about implementing a comparable?
  4. I've been messing around with some things, and am stuck on how I would go about comparing all of the player's deaths in the config.yml. This is what I've thought of:
    Code (Text):
                compareTo(getConfig().getInt("Players." + uuid + ".Kills"));