FallenMoonNetwork / CanaryLib

16 stars 31 forks source link

setScoreObjectivePosition(ScorePosition, ScoreObjective, player) not working #142

Open svdragster opened 11 years ago

svdragster commented 11 years ago
    Scoreboard sc = Canary.scoreboards().getScoreboard(player.getWorld());
    ScoreObjective obj = sc.getScoreObjective("Something_that_definetly_exists.");
    obj.setDisplayName("Scoreboard Title");
            Score timeleft = sc.getScore("Time left", obj);
    timeleft.setScore(30);

    for (int i=0; i<player.getWorld().getPlayerList().size(); i++) {
        Canary.getServer().message(i + ": " + player.getWorld().getPlayerList().get(i)); // Displays my name
        //sc.setScoreObjectivePostion(ScorePosition.SIDEBAR, obj); // Works
        sc.setScoreObjectivePostion(ScorePosition.SIDEBAR, obj, player.getWorld().getPlayerList().get(i)); // Does not work
    }
ayyron-dev commented 11 years ago

@svdragster

You need to use the addScoreboard() methods in Scoreboard to first add a new ScoreObjective to the scoreboard.

When you call ScoreObjective obj = sc.getScoreObjective("Something_that_definetly_exists."); it is returning a null object because it does not exist. it was never added.

After that when you do this:

sc.setScoreObjectivePostion(ScorePosition.SIDEBAR, obj, player.getWorld().getPlayerList().get(i)); // Does not work

it does not work because obj is null.

svdragster commented 11 years ago

@somners I added the objective ingame via the scoreboard command. As mentioned the other method works perfectly, only the second one with Player does not make the sidebar appear.

ayyron-dev commented 11 years ago

This has been investigated more. This feature may have to be dropped unless we do a near rewrite of the scoreboards system.

ayyron-dev commented 11 years ago

alright, so implementing to work 'per player' in this manner would be improper. The method for updating every player still works. I'll be working on something relevant to this after the update to 1.7.2