What's best way to sort map by Integer values ?

Discussion in 'Plugin Development' started by Ibas, Sep 2, 2013.

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

    Ibas

    Hello, I'm making command /xray which would return top 10 players which broke diamond ores most per 24 hour.

    Some piece of code:

    Code:java
    1. public static Map<Player,Integer> xray = new HashMap<Player,Integer>();
    2.  
    3. @EventHandler
    4. public void xray(BlockBreakEvent e) {
    5. if(e.getBlock().getType() == Material.DIAMOND_ORE){
    6. if(!xray.containsKey(e.getPlayer())){
    7. xray.put(e.getPlayer(), 1);
    8. }
    9. else{
    10. xray.put(e.getPlayer(), xray.get(e.getPlayer()) + 1);
    11. }
    12. }
    13. }


    And when you would type /xray it would return top 10 players, which broke diamond ores most.
     
  2. Offline

    frymaster

Thread Status:
Not open for further replies.

Share This Page