Solved Player with highest integer in HashMap

Discussion in 'Plugin Development' started by MordorKing78, Sep 14, 2016.

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

    MordorKing78

    I'm not entirely sure why this isn't working, well it does do something but it doesn't do what I want it to do.
    Code:
        public Player bestPlayer(){
            int highestNumber = 0;
            Player highestPlayer = null;
            
            for (Player player : plugin.playerScore.keySet()) {
                if(plugin.playerScore.get(player) > highestNumber){
                    highestNumber = plugin.playerScore.get(player);
                    highestPlayer = player;
                    return highestPlayer;
                }
            }
            return highestPlayer;
        }
     
  2. Online

    timtower Administrator Administrator Moderator

  3. Offline

    MordorKing78

    @timtower Thanks, I didn't even notice :3

    @AlvinB it's fixed now, thanks for the response :)
     
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page