Scoreboard Teams

Discussion in 'Plugin Development' started by Vixelate, Apr 15, 2014.

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

    Vixelate

    Hi!

    I'm trying to get a scoreboard set up with teams but I can't get it to work. When I added it on a server there were no teams registered. The same thing happend when I added a health scoreboard, though with the health scoreboard my health was visible in the player list but there were no objectives registered.

    Does anyone know how to set up teams?
    Also, how can I add players into a team with a command like "/blue <player>".
    Thanks!


    Code:java
    1. public class Core extends JavaPlugin implements Listener{
    2.  
    3. @Override
    4. public void onEnable() {
    5. getLogger().info("Team plugin enabled!");
    6. getServer().getPluginManager().registerEvents(this, this);
    7.  
    8.  
    9. //Scoreboards
    10. ScoreboardManager sbManager = Bukkit.getScoreboardManager();
    11. Scoreboard sBoard = sbManager.getNewScoreboard();
    12.  
    13. //Teams
    14. Team red = sBoard.registerNewTeam("red");
    15. Team blue = sBoard.registerNewTeam("blue");
    16.  
    17. //Color
    18. red.setPrefix(ChatColor.RED + "");
    19. blue.setPrefix(ChatColor.BLUE + "");
    20.  
    21. //FriendlyFire (false)
    22. red.setAllowFriendlyFire(false);
    23. blue.setAllowFriendlyFire(false);
    24.  
    25. blue.addPlayer(Bukkit.getOfflinePlayer("Vixelate"));
    26.  
    27.  
    28.  
    29. //Health Scoreboard
    30. Scoreboard pHealth = sbManager.getNewScoreboard();
    31. Objective health = pHealth.registerNewObjective("playerHealth", "health");
    32. health.setDisplaySlot(DisplaySlot.BELOW_NAME);
    33. health.setDisplaySlot(DisplaySlot.PLAYER_LIST);
    34. health.setDisplayName("Health");
    35.  
    36. for (Player player : Bukkit.getOnlinePlayers())
    37. player.setScoreboard(pHealth);
    38.  
    39. }
     
  2. Do you mean there are no Objectives registered if you do /scoreboard objectives list ?
    I think that's normal. I worked with the scoreboard several times and everything worked but it wasn't actually displayed in this "list" command.
     
  3. Offline

    Vixelate

    Zeryther Yes. But the teams still doesn't work for some reason.
     
Thread Status:
Not open for further replies.

Share This Page