Scoreboard setDisplaySlot per Player

Discussion in 'Plugin Development' started by iZanax, Apr 21, 2014.

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

    iZanax

    The problem I'm facing is that I can't setDisplaySlot of an Objective per player.
    The Objective will be shown at every player who has this certain Scoreboard.
    So is it possible to only show the Objective to one player and how?

    Source:
    https://github.com/Wolvereness/Craf...et/minecraft/server/ScoreboardServer.java#L35

    Thanks in advance,
    Zanax

    Code:java
    1. // the Objective is just from Bukkit API
    2. setDisplayObjective(player, 1, objective.getName());
    3.  
    4. public static void setDisplayObjective(Player player, int position, String scorename) {
    5. ProtocolManager pm = ProtocolLibrary.getProtocolManager();
    6. PacketContainer pc = pm.createPacket(PacketType.Play.Server.SCOREBOARD_DISPLAY_OBJECTIVE);
    7.  
    8. pc.getIntegers().write(0, position); // 0 = list and 1 = sidebar and belowname = 2
    9. pc.getStrings().write(0, scorename); // the unique name for the scoreboard to be displayed
    10.  
    11. try {
    12. pm.sendServerPacket(player, pc);
    13. e.printStackTrace();
    14. }
    15. }
    16.  


    This doesn't make it crash, but also have no effect at all.
    Can someone can help me out?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    TryB4

    iZanax
    Why are you using that instead of the scoreboard api?
     
  3. Offline

    iZanax

    TryB4
    because setDisplaySlot(DisplaySlot displayslot) will change all players with the same scoreboard to that specific Objective at the displayslot.
    So I want to have a personal Objective for each player with one Scoreboad.
    As u can see in the Source u see SendAll() So ive tried to send it just to he right person, but without succes. : (
     
  4. Offline

    Gater12

    iZanax
    So? You make a new Scoreboard object per player with the scoreboard having it's own little variables.
     
  5. Offline

    iZanax

    Gater12
    I have that at the moment, but I need 1 Scoreboard to handle the teams as well.
    Im hoping that someone can help me out with the packets to make it only appear to one player.
     
  6. Offline

    iZanax

    *BUMP*

    Could anyone help me out with this problem?
    "An Objective at DisplaySlot.SIDEBAR for each player in one Scoreboard"
     
  7. Offline

    iZanax

    *Bump*
     
  8. Offline

    iZanax

    *Bump*
     
  9. Offline

    iZanax

    *Bump*
    This would really improve Scoreboard management, when handeling teams and such.
     
  10. Offline

    iZanax

    *Bump*
     
  11. Offline

    TGRHavoc

    iZanax
    Like Gater12 said, create a new scoreboard objective per player.
    This is what I have:
    Code:java
    1. public void updateScore(Player player, Integer kills){
    2. scoreBoard = scoreManager.getNewScoreboard();
    3. objective = scoreBoard.registerNewObjective("KillStreak", "dummy");
    4. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    5. objective.setDisplayName("Kill Streak");
    6. Score madeBy = objective.getScore(ChatColor.AQUA + "Made By");
    7. madeBy.setScore(-1);
    8. Score tgrhavoc = objective.getScore(ChatColor.GOLD + "TGR_Havoc!");
    9. tgrhavoc.setScore(-2);
    10. Score score = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.GREEN + "Total Kills:"));
    11. score.setScore(kills);
    12. player.setScoreboard(scoreBoard);
    13. }
     
  12. Offline

    iZanax

    TGRHavoc
    Like I explained is that I want to avoid creating a Scoreboard for each player.
    Since I also have to dupe each team for each Scoreboard again, which is in my view kinda a resource waste.
    So I was looking for a way that probably will use packets to make this work with just 1 Scoreboard.

    Thanks for the thoughts though.
     
  13. Offline

    TGRHavoc

    iZanax
    So wait, what exactly are you wanting to acompish? What exactly are you wanting the player to see in the scoreboard?
     
  14. Offline

    fireblast709

    iZanax likes this.
Thread Status:
Not open for further replies.

Share This Page