Scoreboards not getting updated?

Discussion in 'Plugin Development' started by Zarkopafilis, Jul 20, 2014.

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

    Zarkopafilis

    Code called on startup:

    Code:
    //in Data class
    public static Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
        public static Objective objective = Data.board.registerNewObjective("level", "dummy");
       
        public static void init(){
        objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
        objective.setDisplayName(ChatColor.GREEN + " LEVEL");
        }
    Code called on player join :

    Code:
    e.getPlayer().setScoreboard(Data.board);
            Data.objective.getScore(p).setScore(level);
    Code called on levelup:
    Code:
    Data.objective.getScore(p).setScore(level);;
     
  2. Offline

    The Fancy Whale

    Provide some more code? What is p? What is level? When/what isn't updating about it?
     
  3. Offline

    Zarkopafilis

    p : Player
    level : Player's level(not 0 or null - thats tested)
    level stays 0 all times
     
  4. Offline

    Necrodoom

    But what is level?
    Paste full class please.
     
    xTigerRebornx likes this.
  5. Offline

    Dubehh

    Necrodoom
    probably
    Code:java
    1. int level = p.getLevel();

    But you're right.
     
  6. Offline

    Zarkopafilis

    level is virtual (I get it from database)

    BUUUUMP

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

    MCForger

    Zarkopafilis
    Is there any errors? Also whats the point of having the init if your init the Scoreboard object outside of the method? Also why are you so hesitant to post the whole class?
     
  8. Offline

    Zarkopafilis

    1) I access the scoreboard through many classes
    2)The score stays 0
    3) I cant post 3-4 different classes so I posted the code that refers to the scoreboard thing and I said which get called when/where
     
  9. Offline

    stormneo7

    Well what's the database returning?
    System.out.println(level); is a great way to start.
     
  10. Offline

    fireblast709

    Zarkopafilis don't just debug what level is in the end, debug every little step you take in the whole process
     
    Zarkopafilis likes this.
  11. Offline

    Zarkopafilis

    The level of each player . mine is 31 actually , a friend's is 23
     
  12. Offline

    Zarkopafilis

    A friend gave me a piece of his code and take a look ... (wtf???)
    fireblast709
    Code:
     @EventHandler
      public void onJoin(PlayerJoinEvent e) { Player p = e.getPlayer();
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard board = manager.getNewScoreboard();
        Objective objective = board.registerNewObjective("showlevel", "level");
        objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
        objective.setDisplayName(ChatColor.GREEN + " LVL");
        p.setScoreboard(board);
        for (Player online : Bukkit.getOnlinePlayers()) {
          online.setScoreboard(board);
          Score score = objective.getScore(online);
          score.setScore(level);
        }
        for (Player online : Bukkit.getOnlinePlayers())
          online.setScoreboard(board);
      }
    }
     
  13. Offline

    Zarkopafilis

Thread Status:
Not open for further replies.

Share This Page