Clear scoreboard

Discussion in 'Plugin Development' started by ChiicoFlash, Nov 14, 2013.

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

    ChiicoFlash

    Hello!

    I am getting the top from a database and inserting it in the scoreboard.

    I need to remove ALL users scoreboard after X time.

    This is my code (not working):

    Code:java
    1. manager = Bukkit.getScoreboardManager();
    2. board = manager.getNewScoreboard();
    3. objective = board.registerNewObjective("Top", "dummy");
    4.  
    5. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    6.  
    7. Bukkit.getScheduler().scheduleSyncRepeatingTask(instance,
    8. new Runnable() {
    9.  
    10. @Override
    11. public void run() {
    12. Random r = new Random();
    13. int f = r.nextInt(3) + 1;
    14. board.clearSlot(DisplaySlot.SIDEBAR);
    15.  
    16. // 1 = Top de asesinos
    17. if (f == 1) {
    18. objective.setDisplayName(ChatColor.RED
    19. + "Top de asesinos");
    20.  
    21. for (Map.Entry<String, Integer> entry : TopKillsScoreboard
    22. .entrySet()) {
    23. BGMain.sendScore(BGMain.objective,
    24. entry.getKey(), entry.getValue(), false);
    25. }
    26.  
    27. } else if (f == 2) {
    28.  
    29. // 2 = Top de ganadores
    30. objective.setDisplayName(ChatColor.RED
    31. + "Top de ganadores");
    32.  
    33. for (Map.Entry<String, Integer> entry : TopWinnersScoreboard
    34. .entrySet()) {
    35. BGMain.sendScore(BGMain.objective,
    36. entry.getKey(), entry.getValue(), false);
    37. }
    38.  
    39. } else if (f == 3) {
    40.  
    41. // 3 = Top de muertes
    42. objective.setDisplayName(ChatColor.RED
    43. + "Top de muertes");
    44.  
    45. for (Map.Entry<String, Integer> entry : TopDeathsScoreboard
    46. .entrySet()) {
    47. BGMain.sendScore(BGMain.objective,
    48. entry.getKey(), entry.getValue(), false);
    49. }
    50. }
    51.  
    52. }
    53.  
    54. }, 0L, 1200L);
     
  2. Offline

    death923

    create a new scoreboard which is null and set there scoreboard as that...
     
  3. Offline

    Alvarez96

    Player p;
    ScoreboardManager mng;
    p.setScoreboard(mng.getNewScoreboard());
     
  4. Offline

    ChiicoFlash


    No other way? I do not want to create another scoreboard, if not I want to modify the existing one.
     
  5. Offline

    Alvarez96

    ChiicoFlash This is the way I accomplished a clear. It has been a while, but I believe this was the easiest way to do so.
     
  6. Offline

    ChiicoFlash


    I want to delete ALL "scores" that is inside the scoreboard, do not want to create one by one :S
     
Thread Status:
Not open for further replies.

Share This Page