Top Killers

Discussion in 'Plugin Development' started by NewPluginer123, Jan 21, 2015.

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

    NewPluginer123

    Im making Top Killers

    The Main Code :
    Code:
        public void topKills(Player player) {
            Map<String, Integer> scoreMap = new HashMap<String, Integer>();
            List<String> finalScore = new ArrayList<String>();
            for (OfflinePlayer oPlayer : Bukkit.getOfflinePlayers()) {
                if (!oPlayer.isBanned()) {
                    scoreMap.put(oPlayer.getName(), Integer.valueOf(getConfig().getInt("Stats.Player." + oPlayer.getUniqueId() + ".Kills")));
                }
            }
           
            int topScore;
           
            for (int i = 0; i < 10; i++) {
                String topName = "";
               
                topScore = 0;
               
                for (String playerName : scoreMap.keySet()) {
                    int myScore = ((Integer) scoreMap.get(playerName)).intValue();
                   
                    if (myScore > topScore) {
                        topName = playerName;
                        topScore = myScore;
                    }
                }
               
                if (topName.equals("")) {
                    break;
                }
               
                scoreMap.remove(topName);
               
                int position = i + 1;
                int kills = getConfig().getInt("Stats.Player." + topName + ".Kills");
                if(position == 1){
                    String finalString = "§a" + position + ". " + topName + " " + "= " + kills + " Kills";
                    finalScore.add(finalString);
                }
                if(position == 2){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);
                }
                if(position == 3){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 4){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 5){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 6){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 7){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 8){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 9){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
                if(position == 10){
                String finalString = "§3" + position + ". " + "§6" + topName + " " + "= " + "§b" + kills + " §6Kills";
                finalScore.add(finalString);   
                }
            }
           
            List<String> myTop5 = finalScore;
           
            for (String s : myTop5) {
                player.sendMessage(s);
            }
        }
    The Line that i need help:

    Code:
     int topScore;
           
            for (int i = 0; i < 10; i++) {
                String topName = "";
               
                topScore = 0;
               
                for (String playerName : scoreMap.keySet()) {
                    int myScore = ((Integer) scoreMap.get(playerName)).intValue();
                   
                    if (myScore > topScore) {
                        topName = playerName;
                        topScore = myScore;
                    }
                }
                
    I want to change it to getUniqueId, the players UUID.
    not the name and i can't i dont know how, please help
     
    GrandmaJam likes this.
  2. Offline

    SuperOriginal

    Then store the Player's UUID as a string and use that....
     
    GrandmaJam likes this.
  3. Offline

    NewPluginer123

    Can u make more explantion ? didnt got this
     
  4. Offline

    CraftCreeper6

    @NewPluginer123
    Get your UUID...
    UUID uuid = ...

    Then convert it to a string...
    uuid._________();

    Here's a tip. You want it to be a string. Look at the methods that intellisence gives you.
     
  5. Offline

    NewPluginer123

    Sorry i dont know how.. im new in all this UUID
     
  6. Offline

    CraftCreeper6

    @NewPluginer123
    This is more a Java aspect. You should really learn Java before Bukkit.
     
    GrandmaJam likes this.
Thread Status:
Not open for further replies.

Share This Page