Scoreboard Updating

Discussion in 'Plugin Development' started by Captain Dory, Apr 18, 2014.

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

    Captain Dory

    Hi there,

    I'm using a scoreboard for an aspect of my minigame but I'm having some troubles,
    The scoreboard is not updating. My code:
    Scoreboard:
    PHP:
    public class Scoreboard implements Listener {
     
        private 
    org.bukkit.scoreboard.Scoreboard board;
        private 
    org.bukkit.scoreboard.Objective koth;
     
        private 
    Score redScore;
        private 
    Score blueScore;
     
        @
    SuppressWarnings("deprecation")
        public 
    Scoreboard() {
       
            
    board Bukkit.getScoreboardManager().getNewScoreboard();
            
    koth board.registerNewObjective("koth""dummy");
            
    koth.setDisplaySlot(DisplaySlot.SIDEBAR);
            
    koth.setDisplayName(ChatColor.BOLD "KOTH");
            
    redScore koth.getScore(Bukkit.getOfflinePlayer(ChatColor.RED "Red Score"));
            
    redScore.setScore(3);
            
    blueScore koth.getScore(Bukkit.getOfflinePlayer(ChatColor.BLUE "Blue Score"));
            
    blueScore.setScore(1);
       
        }
     
        public 
    org.bukkit.scoreboard.Scoreboard getScoreboard() {
       
            return 
    board;
       
        }
     
        public 
    Integer getRedScore() {
       
            return 
    redScore.getScore();
       
        }
     
        public 
    Integer getBlueScore() {
       
            return 
    blueScore.getScore();
       
        }
     
        public 
    void setRedScore(Integer toSet) {
       
            
    redScore.setScore(toSet);
       
        }
     
        public 
    void setBlueScore(Integer toSet) {
       
            
    blueScore.setScore(toSet);
       
        }
     
        public 
    void incRedScore(Integer increment) {
       
            
    setRedScore(getRedScore() + increment);
       
        }
     
        public 
    void incBlueScore(Integer increment) {
       
            
    setBlueScore(getBlueScore() + increment);
       
        }
     
        @
    EventHandler
        
    public void onJoin(PlayerJoinEvent e) {
       
            
    e.getPlayer().setScoreboard(board);
       
        }
     
    }
    Adding points:
    PHP:
    @EventHandler
        
    public void onMove(PlayerMoveEvent e) {
       
            
    Player p e.getPlayer();
       
            if (
    p.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.BEACON) {
           
                
    Scoreboard s = new Scoreboard();
           
                if (
    Game.blue.contains(p.getUniqueId())) {
               
                    
    s.incBlueScore(2);
               
                } else if (
    Game.red.contains(p.getUniqueId())) {
               
                    
    s.incRedScore(2);
               
                }
               
            } else {
           
                return;
           
            }
       
        }
    There are no errors in console or IDE.
    Any help would be appreciated :)
     
  2. Offline

    The Fancy Whale

    Every time you want the scoreboard to update, make a method where it removes the scoreboard and sets the new one, and call it like reloadBoard(Player).
     
  3. Offline

    Captain Dory

    I'll try this. A few weeks ago I didn't have to do this though- What has changed that I'm doing wrong?
     
Thread Status:
Not open for further replies.

Share This Page