Scoreboard teams

Discussion in 'Plugin Development' started by lukewizzy, Feb 24, 2014.

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

    lukewizzy

    Hi, I had some problems with scoreboards that I posted the other day but I still can't work out my team problems. This is in my onEnable:
    Code:java
    1. data.redTeam.setPrefix(ChatColor.RED + "test - ");
    2. data.redTeam.setAllowFriendlyFire(false);
    3. data.blueTeam.setPrefix(ChatColor.BLUE + "test - ");
    4. data.blueTeam.setAllowFriendlyFire(false);


    This is in the data class (initialized above the onEnable like this: public final Data data = new Data (this); ) :
    Code:java
    1. public ScoreboardManager teamMan;
    2. public Scoreboard teamBoard;
    3. public Objective teamKills;
    4. public Team redTeam;
    5. public Team blueTeam;


    I'm adding people to the teams like this: data.blueTeam.addPlayer(player);

    My issue is that friendly fire is not disabled and my prefixes do not work, although it registers that I'm in the blue team (if I check with data.blueTeam.hasPlayer(player)).

    Also when I try and set the scoreboard to the sidebar it doesn't work (I've added debug messages either sides and those show up):
    Code:java
    1.  
    2. plugin.data.teamKills.setDisplaySlot(DisplaySlot.SIDEBAR);
    3. plugin.data.teamKills.setDisplayName(ChatColor.GOLD + "Team Kills");
    4. plugin.data.redScore.setScore(0);
    5. plugin.data.blueScore.setScore(0);


    Any help is appreciated.
     
  2. Offline

    lukewizzy

  3. Offline

    Traks

    For showing the sidebar try this
    Code:java
    1. plugin.data.redScore.setScore(1);
    2. plugin.data.redScore.setScore(0);
    3. plugin.data.blueScore.setScore(1);
    4. plugin.data.blueScore.setScore(0);

    Btw, being able to see your full onEnable method would be nicer ;) (Don't see any declarations of the board, teams, etc)
     
  4. Offline

    lukewizzy

    Apologies, I forgot to post that. Here's the full onEnable:
    Code:java
    1. public void onEnable() {
    2. PluginManager pm = getServer().getPluginManager();
    3. Bukkit.getServer().getPluginManager();
    4. getServer().getPluginManager().registerEvents(this, this);
    5. pm.registerEvents(ml, this);
    6. this.saveDefaultConfig();
    7. this.getConfig().options().copyDefaults(true);
    8.  
    9. data.controlMan = Bukkit.getScoreboardManager();
    10. data.controlBoard = data.controlMan.getNewScoreboard();
    11. data.ctrlPoints = data.controlBoard.registerNewObjective("controlpoints", "dummy");
    12. data.neutral = data.ctrlPoints.getScore(Bukkit.getOfflinePlayer(ChatColor.GRAY + "Neutral"));
    13. data.redScore = data.ctrlPoints.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Red Team"));
    14. data.blueScore = data.ctrlPoints.getScore(Bukkit.getOfflinePlayer(ChatColor.BLUE + "Blue Team"));
    15. data.playerMan = Bukkit.getScoreboardManager();
    16. data.playerBoard = data.playerMan.getNewScoreboard();
    17. data.pKills = data.playerBoard.registerNewObjective("playerkills", "dummy");
    18. data.player = data.pKills.getScore(Bukkit.getOfflinePlayer(ChatColor.GOLD + "Player"));
    19.  
    20. data.teamMan = Bukkit.getScoreboardManager();
    21. data.teamBoard = data.teamMan.getNewScoreboard();
    22. data.teamKills = data.teamBoard.registerNewObjective("teamkills", "dummy");
    23. data.redTeam = data.teamBoard.registerNewTeam("redteam");
    24. data.blueTeam = data.teamBoard.registerNewTeam("blueteam");
    25.  
    26. data.redTeam.setPrefix(ChatColor.RED + "test - ");
    27. data.redTeam.setAllowFriendlyFire(false);
    28. data.blueTeam.setPrefix(ChatColor.BLUE + "test - ");
    29. data.blueTeam.setAllowFriendlyFire(false);
    30.  
    31. this.gameSetup();
    32. getLogger().info("The Aura's Conquest PVP plugin is now enabled.");
    33. }

    Here's the gameSetup void:
    Code:java
    1. public void gameSetup() {
    2. if (data.forceMode) {
    3. data.forceMode = false;
    4. } else {
    5. if (Bukkit.getOnlinePlayers().length <= getConfig().getInt("gameinfo.modes.small.maxplayers")) {
    6. data.chosenMode = "small";
    7. data.controlPoints = 0;
    8. } else if (Bukkit.getOnlinePlayers().length > getConfig().getInt("gameinfo.modes.medium.minplayers") && Bukkit.getOnlinePlayers().length <= getConfig().getInt("gameinfo.modes.medium.maxplayers")) {
    9. data.chosenMode = "medium";
    10. data.controlPoints = 3;
    11. } else if (Bukkit.getOnlinePlayers().length > getConfig().getInt("gameinfo.modes.large.minplayers")) {
    12. data.chosenMode = "large";
    13. data.controlPoints = 5;
    14. }
    15. }
    16. Random r = new Random();
    17. int r2 = r.nextInt(getConfig().getInt("gameinfo.modes." + data.chosenMode + ".mapcount"));
    18. data.chosenMap = r2 + 1;
    19. getServer().createWorld(new WorldCreator(data.chosenMode + "map" + data.chosenMap));
    20. for (Player ps : Bukkit.getOnlinePlayers()) {
    21. teamPick(ps, false);
    22. baseCamp(ps);
    23. }
    24.  
    25. // Variables
    26. data.warmupTime = getConfig().getInt("gameinfo.warmuptime");
    27. data.inGameTime = getConfig().getInt("gameinfo.gametime");
    28. data.endTime = getConfig().getInt("gameinfo.endtime");
    29. data.spawnCount = getConfig().getInt("modes." + data.chosenMode + ".spawnCount");
    30. data.mapName = getConfig().getString("maps." + data.chosenMode + ".map" + data.chosenMap + ".name");
    31. data.mapAuthor = getConfig().getString("maps." + data.chosenMode + ".map" + data.chosenMap + ".author");
    32. stateChange(1, getConfig().getInt("gameinfo.warmuptime") + 1);
    33. Framework.plugin.data.gameServer = true;
    34. Framework.plugin.data.inGame = true;
    35. }


    The teamPick and baseCamp methods simply add everyone to a team and spawns them in the start of the game.
     
  5. Offline

    Traks

    lukewizzy I don't understand why turning the friendly fire off doesn't work and why it doesn't give you the prefix... Did this fix the sidebar problem though:
    Code:java
    1. plugin.data.redScore.setScore(1);
    2. plugin.data.redScore.setScore(0);
    3. plugin.data.blueScore.setScore(1);
    4. plugin.data.blueScore.setScore(0);
     
  6. Offline

    lukewizzy

    Sorry, I haven't been coding for a while due to illness.

    It didn't fix anything, no :/
     
Thread Status:
Not open for further replies.

Share This Page