Displaying message twice

Discussion in 'Plugin Development' started by Candle is taken :I, Jul 9, 2015.

Thread Status:
Not open for further replies.
  1. My plugin counts down on the scoreboard from 30 seconds, then it displays the message "Starting game" for some reason it's displaying it twice
    Here's my code that's supposed to display it:
    Code:
        if (number >= 0) {
                            ScoreboardManager sbManager = Bukkit.getScoreboardManager();
                            Scoreboard sBoard = sbManager.getNewScoreboard();
                            Objective obj = sBoard.registerNewObjective("candle", "Seconds");
                            obj.setDisplaySlot(DisplaySlot.SIDEBAR);
                            obj.setDisplayName(ChatColor.YELLOW + "" + ChatColor.BOLD + "xyz Generic Name Craft");
                            Score score = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.BLUE + "Seconds remaining"));
                            score.setScore(number);
                            for (Player player : Bukkit.getOnlinePlayers()) {
                                player.setScoreboard(sBoard);
                                if (number == 0) {
                                    Bukkit.broadcastMessage(ChatColor.RED + "" + ChatColor.BOLD + "Starting game");
                                    player.setScoreboard(sbManager.getNewScoreboard());
    
                                }
     
  2. Offline

    Reynergodoy

    @eventhandler and event registering :)
    if that not helps, sorry i dont have good experience with scoreboards ;-;
     
  3. @Reynergodoy
    Sorry, I don't really understand what you're saying.
    I have @EventHandler if that's what you're saying
     
  4. Offline

    Reynergodoy

    oh sorry, you're saying that it is appearing twice... if that's the case, i dont know how to help you, as i said above, i dont have any experience with scoreboards
     
  5. Offline

    AdamQpzm

    @Candle is taken :I The message doesn't appear twice, it appears once for every player online - that should be enough of a hint to get you to spot it. If not - really look at your code, pay attention to the layout and indentation of it, and based on what you've written, why do you think it's displaying twice? :)


    @Reynergodoy The problem isn't with scoreboards, it's with basic Java :p
     
  6. @AdamQpzm
    oooh I don't know how I missed that :p thanks!
     
Thread Status:
Not open for further replies.

Share This Page