Top Kills Scoreboard?

Discussion in 'Plugin Development' started by maved145, Jul 12, 2014.

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

    maved145

    So I’m making a plugin that stores kills from players, then i want to put it so the top 10 kills are on a scoreboard.

    Atm i have got the kills stored like this.

    Kills:
    {playersuuid}: 15

    So now i want to make it so the top 10 people who have the most kills will be put in a scoreboard.
    I want the scoreboard to update every 5 minutes which i will probably do with a scheduler.
    Now before someone comes and says look it up, i have looked already there have been ways but most of them seem to not work.

    Pretty much all I’m asking is how to list the kills from the config to Most amount of kills to least amount of kills.

    Any help would be greatly appreciated!
     
  2. Offline

    TheMcScavenger

    Go through all of the players, and compare their kills...

    Code:java
    1. for(String s : getConfig().getStringList("kills"){
    2. int kills = getConfig().getInt("kills." + s);
    3. }


    I'd suggest adding them all to a HashMap, and going from there..:

    Code:java
    1. HashMap<Player, Integer> kills = new HashMap<Player, Integer>();
    2. for(String s : getConfig().getStringList("kills"){
    3. int kills = getConfig().getInt("kills." + s);
    4. Player player = Bukkit.getPlayer(s);
    5. kills.put(player, kills);
    6. }
     
  3. Offline

    maved145

  4. Offline

    TheMcScavenger

    Compare all the integers in the hashmap.
     
  5. Offline

    maved145

  6. Offline

    izarooni

  7. Offline

    tommyhoogstra

    He wants the top 10, not number 1 only.

    He would use Collections.sort, then display the top 10 results only
     
    izarooni likes this.
  8. Offline

    maved145

    tommyhoogstra
    So would i have to put all the values and kills in a list then do:
    Collections.sort(list);
    If you could give me a example i’d be so grateful.
     
    dxrknez likes this.
Thread Status:
Not open for further replies.

Share This Page