Problem with scoreboard

Discussion in 'Plugin Development' started by arjanforgames, Dec 18, 2013.

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

    arjanforgames

    So I got this piece of code:
    Code:java
    1. Bukkit.getScheduler().cancelTask(startid);
    2. gameStarted = true;
    3. for(Player playerson : Bukkit.getOnlinePlayers()){
    4. inGame(playerson);
    5. playerson.setScoreboard(sbm.getNewScoreboard());
    6. }


    It's resetting everyone's scoreboard to nothing.
    Now the problem is in the "inGame" function it seems.

    Code:java
    1. public static void inGame(final Player player){
    2. objj.setDisplayName(ChatColor.AQUA + "[" + ChatColor.GOLD + gameMinutes + ":" + gameSeconds + ChatColor.AQUA + "]");
    3. objj.setDisplaySlot(DisplaySlot.SIDEBAR);
    4. kills.setScore(0);
    5. deaths.setScore(0);
    6. Bukkit.getScheduler().scheduleSyncDelayedTask(Main.plugin, new Runnable(){
    7. public void run(){
    8. player.setScoreboard(playBoard);
    9. }
    10. }, 20L);
    11. startGameTimer();
    12. }


    It is not displaying the scoreboard to the player.

    This is all above defined:
    Code:java
    1. static ScoreboardManager gamem = Bukkit.getScoreboardManager();
    2. static Scoreboard playBoard = gamem.getNewScoreboard();
    3. static Objective objj = playBoard.registerNewObjective("kills", "dummy");
    4. public static Score kills = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.YELLOW + "Kills:"));
    5. public static Score deaths = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.YELLOW + "Deaths:"));


    Anyone?
     
  2. Offline

    mrkirby153

    arjanforgames

    For one thing, when the game starts, you are resetting the scoreboard to a new scoreboard which clears it. Also, what is startGameTimer() doing?

    (HINT: It would be helpful if you posted the entire class(es))
     
Thread Status:
Not open for further replies.

Share This Page