Solved Updating Scoreboard

Discussion in 'Plugin Development' started by BustosADD, Apr 24, 2014.

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

    BustosADD

    Before we begin, I understand how to update the red numbers on the scoreboard, but what I can seem to figure out is how to update a custom Score objective. For example, I set a score to = to the objective which gets the score of the offlineplayer which then has a custom name of the number I want it to publish. Here are some screenshots as well as some of the code. Also, this is suppose to update the steps a player takes.
    Custom Number:
    http://prntscr.com/3cwqi5
    What Happens:
    http://prntscr.com/3cwqmx

    Code of custom Name(This is on the Main class):
    Code:
            Score score = objective.getScore(Bukkit.getOfflinePlayer("§3§lBlue Team:"));
            score.setScore(10);
            Score score2 = objective.getScore(Bukkit.getOfflinePlayer(""+ChatColor.BLUE + RunningEvent.blue));
            score2.setScore(9);
    Code of what is suppose to happen:
    Code:
    Main.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer(""+ChatColor.BLUE + Main.score2)).setScore(blue);;
    I want it so the 0 updates instead of making a new a new name called null.

    Please help! Thanks!
     
  2. Offline

    raGan.

    First of all, to get score value, you need to call:
    Code:
    Main.score2.getScore()
    And secondly, you need to make sure Main.score2 object is not null. (it apparently is, that's why "null" text)
     
  3. Offline

    BustosADD

    An example would be appreciated.
     
  4. Offline

    raGan.

    Example of what? Making sure an object is not null?
     
  5. Offline

    BustosADD

    Yea. Can't seem to figure it out.
     
  6. Offline

    raGan.

    Ok.
    Code:
    if(Main.score2 == null) {
        // your object is null :( you better assign something there
       // like Main.score2 = Bukkit.giveMeScoreObjectPls();
    }
     
  7. Offline

    BustosADD

    Wow.. I feel like a noob. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page