Economy Scoreboard

Discussion in 'Plugin Development' started by Jaaakee224, Mar 4, 2014.

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

    Jaaakee224

    I want to implement a feature in my Economy plugin to have a scoreboard for each individual player in the link here.

    I want to implement the same layout of the scoreboard for my Economy plugin. I have tried before doing this and have failed multiple times, you can look on Github here, the link will direct you to the scoreboard code of the plugin GemManager, the plugin in the picture above.

    Please use my code as I have tried to use others and I have failed to do so, the code here has a scoreboard above the player's head to show their balance. I want the scoreboard with the player's balance, to be on the sidebar slot on the scoreboard, that is only visible to that individual player.
    Code:java
    1. package me.Jaaakee224.Economy;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.entity.Player;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerJoinEvent;
    8. import org.bukkit.scoreboard.DisplaySlot;
    9. import org.bukkit.scoreboard.Objective;
    10. import org.bukkit.scoreboard.Scoreboard;
    11.  
    12. public class ScoreboardManager implements Listener {
    13.  
    14. private ScoreboardManager() { }
    15.  
    16. private static ScoreboardManager instance = new ScoreboardManager();
    17.  
    18. public static ScoreboardManager getInstance() {
    19. return instance;
    20. }
    21.  
    22. private Scoreboard board;
    23. Objective o;
    24.  
    25. public void setup() {
    26. board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
    27.  
    28. o = board.registerNewObjective("money", "dummy");
    29. o.setDisplayName("$");
    30. o.setDisplaySlot(DisplaySlot.BELOW_NAME);
    31. }
    32.  
    33. @EventHandler
    34. public void onPlayerJoin(PlayerJoinEvent e) {
    35. Player p = e.getPlayer();
    36.  
    37. p.setScoreboard(board);
    38. }
    39. }


    Thanks if you work with me and help me figure out how to do this :p

    If you need to see more of my project's code, please ask me.
     
  2. Offline

    Regagames

    Try this:
    (Taken from Nauss's topic; https://forums.bukkit.org/threads/tutorial-scoreboards-teams-with-the-bukkit-api.139655/)

    Code:java
    1. ScoreboardManager manager = Bukkit.getScoreboardManager();
    2. Scoreboard board = manager.getNewScoreboard();
    3.  
    4. Objective objective = board.registerNewObjective("lives", "dummy");
    5. objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
    6. objective.setDisplayName("lives");
    7.  
    8. for(Player online : Bukkit.getOnlinePlayers()){
    9. Score score = objective.getScore(online);
    10. score.setScore(5); //Example
    11. }
    12.  
    13. for(Player online : Bukkit.getOnlinePlayers()){
    14. online.setScoreboard(board);
    15. }


    To update the amount of money have, make a loop for about 1 second (20 ticks) and in that put score.setScore(WhereEverYouStoreTheMoneyTheyHave);

    And change the objective to "money", "dummy" and display name to "$"

    By the way, this whole thing would go in a join listener (PlayerJoinEvent)
     
  3. Offline

    Jaaakee224

    Regagames I want to do this for the sidebar though, and look at the first link to see pretty much what I want, with the player's name on top, beneath that gems, and the current balance of that player. I have also provided the code for that plugin and I have tried using it, but failed. (Github link is in the 2nd paragraph.)
     
  4. Offline

    Regagames

    Jaaakee224 I don't seem to understand you? What exactly are you trying to say?
     
  5. Offline

    Jaaakee224

    Regagames Look at the first link I gave, can you explain how to do that but use my code? I tried to do it, I don't know what's wrong :/, look at the 2nd link for the Github repository.
     
  6. Offline

    Jaaakee224

    Can somebody help me?
     
Thread Status:
Not open for further replies.

Share This Page