need help with scoreboard top kills

Discussion in 'Plugin Development' started by Unisteven, Jun 12, 2014.

Thread Status:
Not open for further replies.
  1. hi, i got some problems with my scoreboard it works using
    Code:java
    1. o2 = board2.registerNewObjective("killcount", "playerKillCount");
    2. o2.setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "RebelTopKills" + ChatColor.GREEN + "");
    3. o2.setDisplaySlot(DisplaySlot.SIDEBAR);
    4. o2.getScoreboard().

    but if it gets to much players it will stop displaying can i set a max to how many lines of players it can display?
     
  2. Unisteven I dont think you can bypass this limit, however - you can scroll thru the strings and display them...
     
  3. Unisteven bukkit runnable that "recreating" the scoreboard every few ticks, but with diffrent string in it.
    your list contains : X, Y , Z, U, I, N
    you can fit only 4 letters inside a scoreboard (pretendring, just giving an exmaple :p)
    so what you will do is showing all the players X Y Z and U, after few seconds youll kick off X and show them Y Z U I, etc
     
  4. Someone_Like_You could you give me a code example that would work if i copy it in and ajust it offcource.
     
  5. Unisteven Im not going to spoon feed you, theres 999 ways of doing it, Il help you in one of them, what I would do :
    1. put all the names in arraylist, every X ticks, get some of them (amount that fill up in the scoreboard) and display them to all the players,
    2. take the names you just displayed and add them into a new arraylist and remove them from the first one.
    3. keep doing 1 and 2 untill the first arraylist is empty or almost empty, (arraylist.size() = 0).
    4. take all the names from the new arraylist at 2, and "reset" them into the new arraylist
    it is kind of complicated, Im 100% sure theres easier ways of doing it, the hard part is to think how youll do it :) good luck!
     
  6. Offline

    Ultimate_n00b

    It's not very complicated, here you go. Fix it to work with what you need:

    Code:java
    1. @SuppressWarnings({ "hiding", "rawtypes" })
    2. public static <Player, Integer extends Comparable> Map<Player, Integer> sortByValues(Map<Player, Integer> map) {
    3. List<Map.Entry<Player, Integer>> entries = new LinkedList<Map.Entry<Player, Integer>>(map.entrySet());
    4.  
    5. Collections.sort(entries, new Comparator<Map.Entry<Player, Integer>>() {
    6. @SuppressWarnings("unchecked")
    7. @Override
    8. public int compare(Entry<Player, Integer> o1, Entry<Player, Integer> o2) {
    9. return o1.getValue().compareTo(o2.getValue());
    10. }
    11. });
    12. Map<Player, Integer> sortedMap = new LinkedHashMap<Player, Integer>();
    13. for (Map.Entry<Player, Integer> entry : entries) {
    14. sortedMap.put(entry.getKey(), entry.getValue());
    15. }
    16. return sortedMap;
    17. }


    Simply supply it with a map containing the players and how many points they have, and it will return a map with the highest values first. Not the most beautiful method, but it works.
     
Thread Status:
Not open for further replies.

Share This Page