Solved Updating Scoreboards [SIDEBAR]

Discussion in 'Plugin Development' started by tovd1234, Dec 30, 2014.

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

    tovd1234

    Hello Bukkit, I have made a Scoreboard with a timer, and put it in the sidebar. But the problem is that it does not update. So when I start the timer the text should change. I know this is possible (Because it's done on MinePlex) but I don't know how. How can I solve this? Thanks!

    Code: http://pastebin.com/j4MPKR41
     
  2. Offline

    XgXXSnipz

    @tovd1234 you're best bet would be too create a runnable using scoreboard.Update(); every tick, so it updates with the time
     
  3. Offline

    tovd1234

    @XgXXSnipz Do you mean every 20 ticks? 20 ticks = 1 second.
    But scoreboard.Update(); does not exist!

    Figured it out! In a Runnable you want to make your timer ofcourse. But you also want to add the time displayed on the scoreboard there! And then you want to set your scoreboard alwell!

    Runnable:
    Code:
    this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    
                            @Override
                            public void run() {
                                if (timer != 0) {
                                    timer--;
                                    sBoard.getObjective("stats").getScore(Bukkit.getOfflinePlayer("§eTime left")).setScore(timer);
                                    player.setScoreboard(getScoreboard()); // getScoreboard is where my scoreboard is saved
                                }
                            }
    
                        }, 0L, 20L);
            }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Oct 31, 2016
  4. Offline

    XgXXSnipz

    @tovd1234q glad I could help
     
  5. Offline

    WesJD

  6. Offline

    XgXXSnipz

    @WesJD I started him off with a runnable :p
     
  7. Offline

    WesJD

    @XgXXSnipz
     
  8. Offline

    XgXXSnipz

    @WesJD lol, u are one try hard :p
     
  9. Offline

    tovd1234

    You didn't start me with a runnable?
     
Thread Status:
Not open for further replies.

Share This Page