[Tutorial] Scoreboards/Teams with the Bukkit API

Discussion in 'Resources' started by chasechocolate, Apr 5, 2013.

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


    Hoping you have found your answer by now, but really not sure. Either way, here's some information.

    [ For the lazy ]
    This topic is at the top of the Plugin Development forum
    And this post is the 7th one down in that topic

    [ For the tl;dr ]
    If you're using Eclipse:
    1. Right click your project in the Package Explorer
    2. Select Build Path -> Configure Build Path
    3. Go to the Libraries tab
      • If you don't have Bukkit added here, add it
    4. Go to the Order and Export tab (top near the right side)
      1. Click on Bukkit (middle)
      2. Click Up (right side) until it's higher than CraftBukkit
    5. All done!
    If you're not using Eclipse, then Google how to do it in whatever IDE you use.

    May His Noodliness have mercy on your soul.


    Do you know if there's a way to have each player appear with a different objective under their name? Such that Player A has the objective "Moderator" under his name, and Player B has the objective "Admin" under his name, and Player C can see both Player A and Player B correctly? I've been unable to do this with the standard API, but not sure if you have any idea on how to fake this data though packets.

    Would be really cool to make an API plugin that can do this easily, as server owners could have group names, titles, or any other text under their name. I'd take the leading 0 in front any day. :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Oct 30, 2015
  2. Offline


    Do you know how to separate SIDEBAR teams?, I would like to have titles like:

    player1 5
    player2 8

    player3 0
    player4 7

    So there are 2 teams clearly separated, I don't want them to be mixed.
  3. Offline


    NemesisMate you could try making a score with no name (Bukkit.getOfflinePlayer("")). Since scoreboard scores get organized by score, you will need to find a way to have it be placed in between two other scores.
  4. Offline


    chasechocolate Just that is what I can't find :S, a way to place it between the scores.
  5. Can't seem to figure out this problem. I want the scoreboards to be set and reset at some events. But when i'm setthing the manager and board outside any methods, i get NPE errors on this line: Scoreboard board = manager.getNewScoreboard();.
    how can i set the manager and board outside evertyhing so i can reach them from different methods?
  6. Offline


    Won't show up. I copied the code and edited it to my liking, no errors, no problems but it still wont show up when I run my server. Is it a plugin.yml issue possibly?
  7. Offline


  8. Offline


    WhaleAnarchy You are probably using wrong getHealth(); or havent defined the actual player as a (Player)
  9. Offline


    Anybody know how to create 2 timers in this format:

    5:00 Blitz-SG 20:00
    Kills: 0
    Players: 24
  10. Offline


  11. Yep, i do. My very basic code, that gives an NPE:
    1. ScoreboardManager manager = Bukkit.getScoreboardManager();
    2. Scoreboard board = manager.getNewScoreboard();
    3. Team team = board.registerNewTeam("teamname");
    4. Objective objective = board.registerNewObjective("test", "dummy");

    NPE on Scoreboard line
  12. Offline


    mollekake make sure you are importing the Bukkit scoreboard class as opposed to the NMS scoreboard class.
  13. Offline


    After 3 day's of hard thinking :)p) i dont have any solution for my problem:
    I wrote 2 plugin's: one of them counting points, and second make guild's.
    First plugin is showing points in scoreboard on the right side and now i want second plugin to show prefixes above players head (teams). And now i dont have a clue: How can i do that? If i'll set new scoreboard for player in second plugin, it will override first scoreboard. I tried to save in first plugin a scoreboard per player in metadata and than adding teams in other plugin but now i see its pointless becouse every player will have their own team (?!). So, is that possible to make individual scoreboard for player AND other scoreboard for teams? Sorry for my bad english, if you dont understand i'll try to explain it more clearly :D
  14. Yep got the right imports, had to declare the objects outside the onEnable, then declaring them in then onEnable:
    1. ScoreboardManager manager;
    2. Scoreboard board;

    1. manager = Bukkit.getScoreboardManager();
    2. board = manager.getNewScoreboard();
  15. Offline


  16. Offline


  17. Offline


    Hey, trying to make a Kills scoreboard, I can't figure out how to display the scoreboard to one particular player... I even tried it once and whenever I got a kill, it showed up on everyone's board. Here's my code:
    package me.Dead_Skeleton.kills;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    public class Kills extends JavaPlugin implements Listener {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Objective objective  = board.registerNewObjective("Kills", "dummy");
        Score score = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Kills: "));
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Objective objective  = board.registerNewObjective("Kills", "dummy");
            objective.setDisplayName(ChatColor.RED + "Kills");
            Score score = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Kills: "));
        public void onDisable() {
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
        public void onPlayerDeath(PlayerDeathEvent e) {
            if (e.getEntity() instanceof Player) {
                Player p = e.getEntity();
                if (p.getKiller() instanceof Player) {
                    Player killer = p.getKiller();
                    int killer_score = score.getScore();
                    score.setScore(killer_score + 1);
    That's my only class. Thanks for the help! (Btw, chasechocolate, I love your speed code videos! :D Thanks for the helpful post!)
  18. Offline


    double being your double
  19. Offline


    I wanna let the players join the team with a command :/ What to do ?
  20. Offline


    Create a Team variable, and in the onCommand() method, use team.addPlayer(player).
  21. Offline


    how can I put my own variables in scoreboard (string type or else). Like: points count, rank, players online and e.t.c?
    Thanks for advance!
  22. Offline


    Hello peps, I have this test code:
    2. @EventHandler
    3. public void onPlayerJoin(PlayerJoinEvent e) {
    4. Player p = e.getPlayer();
    5. ScoreboardManager manager = Bukkit.getScoreboardManager();
    6. Scoreboard board = manager.getNewScoreboard();
    7. Objective objective = board.registerNewObjective("test", "dummy");
    8. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    9. objective.setDisplayName("§5§lStats");
    10. Score k = objective.getScore(Bukkit.getOfflinePlayer("§eKills§4:"));
    11. k.setScore(235);
    12. Score d = objective.getScore(Bukkit.getOfflinePlayer("§eDeaths§4:"));
    13. d.setScore(456);
    14. Score kdr = objective.getScore(Bukkit.getOfflinePlayer("§eKDR§4:"));
    15. kdr.setScore(235 / 456);
    16. p.setScoreboard(board);
    17. }
    but whenever a player joins the scoreboard shows for 1 sec or so, do I need to make a repeating task to rest it every sec or what? I have no idea ... probably cuz I'm tired... :eek:

    I will give a Diamond to anyone who solve this xD [diamond]

  23. Offline


    spoljo666 so it removes itself after 1 second? Perhaps another plugin is interfering?
    spoljo666 likes this.
  24. Offline


    chasechocolate, [diamond] to you!!!! I had a plugin that was setting players display names thru the scoreboard API, when I removed it, the scoreboard doesn't disappear anymore. Thanks!
  25. Offline


    score board works on my test server but when i put this on my normal server scoreboard dont appears on right side and there is no console errors why this happening_?
  26. Offline


    Speaw ,
  27. Offline


    I think you have Health Bar installed.

    Does this problem occur without any plugins installed?
  28. Offline


    Hey guys anyone have any idea how to save the scoreboard on player leave/join?
  29. Offline


    DrTURTLE2 I believe the player will keep the same one when they login.
  30. Offline



    Sorry forgot to mention, server restarts/reloads? My bad.
Thread Status:
Not open for further replies.

Share This Page