Scoreboard help?

Discussion in 'Plugin Development' started by coobro123, Jun 15, 2013.

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

    coobro123

    Hi there!

    I just really can't seem to crack the error in my scoreboard. If I could have a small part of code as an example. that would be great. Thankyou
     
  2. Offline

    Deckerz

    Would help if you told us what you want to do and what the error is.
     
  3. Offline

    coobro123

    No stacktrace etc... it just doesn't load I think I am way off what it should be so it would be pointless to put my code in here.
     
  4. Offline

    CubieX

    If you have read the plugin tutorial, you should be able to set up a basic plugin.
    From that point on, we can help you if there are specific errors or questions.
     
  5. Offline

    coobro123

    CubieX I know how to code properly... I am just terrible at setting scoreboards.
     
  6. Offline

    CubieX

    Then please show us you code and tell us what you are trying to do.
    How in heaven should we otherwise know what's wrong? :rolleyes:
     
  7. Offline

    coobro123

    I did state what is wrong. I said I can't add the scoreboard to the player onPlayerJoinEvent. I put the methods in there but it still won't work. The event is registered etc...

    And all I need is a code example...

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

    chasechocolate

  9. Offline

    coobro123

    chasechocolate I did check that. Do u mind a small code example than I can use the method on my PlayerJoinEvent
     
  10. Offline

    Rprrr

    coobro123
    Did you even read the topic?
    Also, no one's going to feed you code.
     
    TheGreenGamerHD likes this.
  11. Offline

    coobro123

    Rprrr I don't steal code... I just need an example and what do u mean by read the topic. I made this post.
     
  12. Offline

    Ad237

    coobro123 Dude, What is so hard about showing us your code? Then we can help you.
     
  13. Offline

    Lauryman

    coobro123 If you show us the code, only then will someone be able to make an example out of it. If you want help, post your code, regardless if it works or is by far the worst code ever but sort of makes sense. Just post the code you have...
     
  14. Offline

    ZeusAllMighty11

    I think the issue here may be that the OP has little to no code at all, and is simply asking for code. Actually, chasechocolate gave you a thread with examples and all the code you will need. If you don't understand this, perhaps you should learn some more Java and play with smaller plugins for a while.
     
  15. Offline

    the_merciless

    a snippet from 1 of my plugins, hopefully it will help you:

    Code:
    public void displayStats(Player p, String pname) {
       
            User user = MercilessPvp.playerdata.get(pname);
     
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard sb = manager.getNewScoreboard();//create an empty scoreboard
     
            Objective stats = sb.registerNewObjective("Stats", "dummy");// create new scoreboard objective.
            stats.setDisplaySlot(DisplaySlot.SIDEBAR); //sets where scores are to be displayed
            stats.setDisplayName("Stats"); // sets the name for the objective (top of sb)
     
            Score rank = stats.getScore(Bukkit.getOfflinePlayer("Rank:")); //Get a fake offline player       
            Score mp = stats.getScore(Bukkit.getOfflinePlayer("Mp:"));
            Score money = stats.getScore(Bukkit.getOfflinePlayer("Money:"));
       
            rank.setScore(user.getRank());// set score value
            mp.setScore(user.getMp());
            money.setScore(user.getMoney().intValue());
               
            p.setScoreboard(manager.getNewScoreboard());
            p.setScoreboard(sb); //displays scoreboard
            }
    Why u all got to be so bitchy, this aint a competition. I learnt most of what i know from looking at other peoples code. Lets try being a little more helpful even if you dont agree with thier choice of learning technique. If you dont want to be helpful, dont come here.
     
  16. Offline

    Lauryman

    the_merciless Isn't that pretty mush exactly what was said in ChaseChocolate's thread?
     
  17. Offline

    the_merciless

    So it is. I never looked. That must of been where I learnt it.
     
  18. Offline

    coobro123

    Ok, I have a diferent error now. And I can code its just that my code was way off... Me being bad at one thing in bukkit doesn't make me terrible. Its just one of those things I can't crack. Anyway, I know how to set it up now etc... But when I set it up onPlayerJoin it just isn't loading up. I tried making a command that gives me the scoreboard, and i also tried then dispatching it. onplayerjoin but still didn't work. The Event works, and the command works, i also tried a delayed and didn't work. no idea what is wrong here is the code i use to set it up.

    Code:
    public static void ShowScoreboard(Player player) {
       
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Objective objective = board.registerNewObjective("test", "dummy");
            objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
            objective.setDisplayName(ChatColor.RED + "Points");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            org.bukkit.scoreboard.Score kills = objective.getScore(Bukkit
                    .getOfflinePlayer(ChatColor.GREEN + "Balance:"));
           
                kills.setScore(((int)Economy.getAmount(player)));
           
                org.bukkit.scoreboard.Score deaths = objective.getScore(Bukkit
                        .getOfflinePlayer(ChatColor.GREEN + "Kills:"));
                      deaths.setScore(Stats.getKills(player));
            player.setScoreboard(board);
        }
     
  19. Offline

    the_merciless

    You can't set it below display name and on the side. Scoreboards under the display name will only use 1 score.

    You can't use economy.getBalance unless you have hooked vault.

    Before you set a new scoreboard you must first remove the 1 they already have. Notice how on my code I set them a new (blank) scoreboard (this will remove anyscoreboard they have displyed) before displaying the 1 I want them to see.

    You need to store the players kills/deaths somewhere yourself and then get that value to set the scores.

    Make sure you read through the links you have been given, and try to understand it as best you can. Copy and pasting it will get you know where.
     
  20. Offline

    coobro123

    the_merciless The Economy.getBalance is my own code. lol, I made my own economy

    EDIT: Thanks heaps merciless c;
     
  21. Offline

    the_merciless

    Ok so where are your errors. You don't need to dispatch a command when a player joins. Just call this method and pass the player in to it
     
  22. Offline

    Lauryman

    Also you said that onPlayerJoin isn't working. Mind posting the code for that, too?
     
  23. Offline

    firecombat4

    Code:
        @EventHandler
        void playerJoin (PlayerJoinEvent event) {
            Player p = event.getPlayer();
            if (p.hasPermission("testing")) {
                displayStats(p);
            }
        }
     
  24. Offline

    keeper317

    Get rid of the if(p.hasPermission("testing"))
    if it displays properly then it is the permission stuff. if not then post your scoreboard code and your main method code the one that extends JavaPlugin
     
  25. Offline

    the_merciless

    This thread is a year old...
     
  26. Offline

    keeper317

    Yea I realized that a few minutes after I posted that.
     
Thread Status:
Not open for further replies.

Share This Page