Checking all players experience levels?

Discussion in 'Plugin Development' started by HeyShibby, Apr 6, 2013.

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

    HeyShibby

    Hello Shibby here, basically what i'm trying to do is check all the players xp level after a certain amount of time, but all i've been able to do is check the 'player' xp but I want to check all players xp level then compare them to see who has the highest or if 2+ people have the same any ways of doing this?​
     
  2. Offline

    MCForger

    HeyShibby
    Make a hash map and store the players name as the key and the exp as the value. Then make some kind of comparing method.
     
  3. Offline

    Burnett1

    Code:
    HashMap<String, Integer> highest = new HashMap<String, Integer>();
    String Highest = null;
    for(Player player : Bukkit.getOnlinePlayers()){
        int lvl = player.getLevel();
        if(highest.isEmpty()){
            highest.put(player.getName(), lvl);
            Highest = player.getName();
        }
        if(lvl > highest.get(Highest)){
            highest.clear();
            highest.put(player.getName(), lvl);
        }
        if(lvl == highest.get(Highest)){
            highest.put(player.getName(), lvl);
        }
     
    }
     
    MCForger likes this.
  4. Offline

    MCForger

    Burnett1
    Thank you, as I am not on a computer and can't whip up some example code.
     
  5. Offline

    Burnett1

    No problem
     
  6. Offline

    HeyShibby

    wow I was trying to do it such a complicated way up to this thanks(y)
     
Thread Status:
Not open for further replies.

Share This Page