Scoreboard question - different sidebar for each player?

Discussion in 'Plugin Development' started by WauloK, Jun 15, 2015.

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

    WauloK

    Is it possible for each player to have a different scoreboard or does it show the same board for everyone?

    I wrote a plugin and created a new team for each player. One player joins and it shows two stats for them, but when a second player joins the game, it flickers between the two scores on both screens.
     
  2. Yes.

    Can we see the code?
     
  3. Offline

    WauloK

    I expect I need a different object per player and add it to that or something.

    Code:
            //Set up Scoreboard
            Scoreboard board = InsanityRun.board;
            Team team = board.registerNewTeam(playerName);
            player.setScoreboard(InsanityRun.board);
            team.setDisplayName(playerName);
            InsanityRun.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            InsanityRun.objective.setDisplayName(ChatColor.WHITE + "Insanity Run : " + ChatColor.GREEN + playerName);
            Score score = InsanityRun.objective.getScore(ChatColor.YELLOW + "Coins:");
            score.setScore(0);
            Score time = InsanityRun.objective.getScore(ChatColor.LIGHT_PURPLE + "Time:");
            time.setScore(0);
    Code:
                            Score score = InsanityRun.objective.getScore(ChatColor.YELLOW + "Coins:");
                            score.setScore(coinsOwned);
    Maybe the sidebar can only be the same for everyone.
     
    Last edited by a moderator: Jun 16, 2015
  4. Offline

    RingOfStorms

    If you want each player's scoreboard to show different content, like coins, then you'll have to make a separate scoreboard for every single player and update them individually to show the right content for each player. Otherwise you can assign the same scoreboard object to all players, but then they will all see the same exact thing, making dynamic stats like coins impossible.
     
  5. Offline

    WauloK

    So adding them all as different teams doesn't give them a different scoreboard?

    Should this be a different board for each player?

     
  6. You have to create a new scoreboard for each palyer, you're just using the same.
    Code:
    Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
    
     
  7. Offline

    WauloK

    Thanks, guys! Got it all sorted :)
     
Thread Status:
Not open for further replies.

Share This Page