Scoreboard Teams help

Discussion in 'Plugin Development' started by gamerguy115, Apr 26, 2015.

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

    gamerguy115

    I created this whole thing in my onEnable() to create scoreboard. I want to use this scoreboard in a custom command so I could add players to the teams. But, I can't access the Teams because they were only sepcified in the onEnable(). Is there any workaround for this?
     
  2. Offline

    RainoBoy97

    A simple "workaround" is to move the fields to outside the onEnable method.
     
  3. Code:
    public class YourPluginMain extends JavaPlugin {
    
    private Scoreboard board;
    private Team team;
    
    @Override
    public void onEnable() {
          board = Bukkit.getScoreboardManager().getNewScoreboard();
          team = board.registerNewTeam("YourTeam");
    }
    
    public Scoreboard getScoreboard() {
       return board;
    }
    
    public Team getTeam() {
       return team;
    }
    }
    
     
Thread Status:
Not open for further replies.

Share This Page