Scoreboard Help

Discussion in 'Plugin Development' started by JPG2000, Nov 9, 2013.

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

    JPG2000

    Pre-Note: Before you comment with things like "Google before hand" or "Learn java" I have, with both examples. I've researched a lot and have NOT found something that helps me, and I do know java - Methods objects etc. I just need some help with Scoreboards.

    Hello!
    1) With chasechocolate thread, I have found how to make scoreboards with objectives. But what I don't understand is how would I have multiple "criteria" for example, a scoreboard can say "Stats" then Kills, Deaths, Coins etc. Those are what I refer to as "criteria". I saw that you can half multiple scores, but what I don't understand, is that when you use "board.getScore(player)" it gets a score, then how would I get a score if I have multiple scores? Basicly, how would I go about having separate things like "Ki'lls" and "Deaths". Would I need multiple objectives?

    2) I don't understand objectives. Do I need multiple objectives per board? If I want an objective to keep track of scores and deaths(via criteria) then how would I merge them into one board?

    Thanks in advanced, any code or words of wisdom will be appreciated!

    - Jake

    EDIT: Also, don't like me with http://forums.bukkit.org/threads/tutorial-scoreboards-teams-with-the-bukkit-api.139655/, Its useful but I still don't understand some things - see my questions above :p

    So basicly, how would I do this:
    [​IMG]

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

    BillyGalbreath

  3. Offline

    Gater12

  4. Offline

    BillyGalbreath

    Well if you still dont understand idk what else to tell you... Its pretty clear cut.

    Code:
    // Get the Bukkit ScoreboardManager which handles all Scoreboards from all plugins
    ScoreboardManager manager = Bukkit.getScoreboardManager();
    
    // Create a new Scoreboard object for us to use here in this plugin
    Scoreboard board = manager.getNewScoreboard();
    
    // Create a new Objective on the Scoreboard we created above and set some details of it
    Objective objective = board.registerNewObjective("test", "dummy");
    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    objective.setDisplayName("Blockminers");
    
    // Create new scores on the above Objective, which is on the Scoreboard we created way up top
    Score money = objective.getScore(Bukkit.getOfflinePlayer("Money"));
    Score deaths = objective.getScore(Bukkit.getOfflinePlayer("Deaths"));
    Score level = objective.getScore(Bukkit.getOfflinePlayer("Level"));
    Score pvp = objective.getScore(Bukkit.getOfflinePlayer("PvP"));
    Score kd = objective.getScore(Bukkit.getOfflinePlayer("K/D"));
    Score pve = objective.getScore(Bukkit.getOfflinePlayer("PvE"));
    Score score = objective.getScore(Bukkit.getOfflinePlayer("Score"));
    
    // Lets change the score of "money"
    money.setScore(500);
    
    // Now lets attach this scoreboard to a player's screen, which is already populated with scores on an objective on the scoreboard.
    player.setScoreboard(board);
    
    Edit: Added comments for clarity
     
  5. Offline

    1Rogue

    What part of the above code confuses you?
     
  6. Offline

    JPG2000

    BillyGalbreath You really just connected me! Thanks so much!

    BillyGalbreath 1Rogue So what I don't get above, is your just getting a score object, but you never set the score to the board?

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

    BillyGalbreath

    the Score is connected to the Objective, which is connected to the Scoreboard
     
  8. Offline

    1Rogue


    When you call "getScore()" it will create a new score object if it does not exist, which you can then manipulate as neccesary.
     
    JPG2000 likes this.
  9. Offline

    BillyGalbreath

    I've edited my post adding comments to the code for clarity.
     
  10. Offline

    JPG2000

    BillyGalbreath Thanks! :p

    BillyGalbreath 1Rogue So Im understanding is with your code, its setting the scores automatically to 0. Now, it would show "o" to every player. How would I make it show differently for each player? If I had a HashMap storing a String (name) and a Score, then how could I set each score only for the player?

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

    BillyGalbreath

    Thats as far as my experience goes. But to guess, you would ne a completely new scoreboard/objective for each user to have their own readout like that.
     
  12. Offline

    JPG2000

Thread Status:
Not open for further replies.

Share This Page