Scoreobard number won't update properly

Discussion in 'Plugin Development' started by Creeoer, Nov 23, 2014.

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


    Rather odd problem,

    So this code here is in my constructor and a new instance of it is created in the player join event. Anyways, the editor file is where hte kills are stored, and the kills are stored fine.

    FileConfiguration killer = null;
    File editor = new File(NameTags.getInstance().getDataFolder() + File.separator + "KillerStorage.yml");
    killer = YamlConfiguration.loadConfiguration(editor);
    Objective killss = board.registerNewObjective("kills", "dummy");
    Score killie = killss.getScore(player);
    int kills = killer.getInt("PlayerKills." + pName);
    ChatColor color = getColor(configuration);
    if(displayKills == true) {
        //Display objective
        killss.setDisplayName(color +"TotalKills");
    This is what the killerstorage file looks like:
      creeoer: 1
    Fine right? However int will always be displayed as 0 in the scoreboard, and I can't tell why?

    EDIT: The kills are handled in a seperate event, so the kills in the file not updating is not the problem.
  2. Offline


    Creeoer I have a few guesses at what it could be, but their not great guesses:
    Are you sure displayKills is true?
    Could you have a typo in the name "KillerStorage.yml"?
    Are you sure that pName is the player's name?

    Does the plugin work when you update the kills after killing someone? I know there are sometimes problems with PlayerJoinEvents because they are handled before the player actually joins, so you might not be able to set their scoreboard properly. You could try adding a delay of a second before running your code.
  3. Offline



    Are you actually updating the scoreboard?
    Aside from updating a score, you have to update the entire scoreboard too.
    Like, resetting it.
Thread Status:
Not open for further replies.

Share This Page