Scoreboard Teams not Working

Discussion in 'Plugin Development' started by WitchCraftMC, Aug 18, 2014.

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

    WitchCraftMC

    Hello! I was wondering why my Scoreboard teams wasnt creating the teams. I have tried alot of stuff but I am a beginner developer and just wondering so here is the code:
    Code:
            // START OF SBTEAMS
            if(commandLable.equalsIgnoreCase("ct")) {
                ScoreboardManager manager = Bukkit.getScoreboardManager();
                Scoreboard board = manager.getNewScoreboard();
                // CREATING TEAMS
                Team red = board.registerNewTeam("red");
                Team blue = board.registerNewTeam("blue");
                // FRIENDLY FIRE
                red.setAllowFriendlyFire(false);
                blue.setAllowFriendlyFire(false);
                // SEE FRIENDLY INVIS.
                red.setCanSeeFriendlyInvisibles(true);
                blue.setCanSeeFriendlyInvisibles(true);
                // SUFFIX
                red.setSuffix(ChatColor.GRAY + "[" + ChatColor.RED + "RED" + ChatColor.GRAY + "]" + ChatColor.RESET);
                blue.setSuffix(ChatColor.GRAY + "[" + ChatColor.BLUE + "BLUE" + ChatColor.GRAY + "]" + ChatColor.RESET);
                // SUCCESS MSG
                player.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Succesfully Created Teams!");
     
            }
            // END OF SBTEAMS
     
  2. Offline

    EncomSoft

  3. Offline

    Forseth11

    Any stack trace?
     
  4. Offline

    Dubehh

    WitchCraftMC

    I think (not sure) that you have to load the Scoreboard + teams into the onEnable method.
    Else, you might want to be more specific (Errors, warnings, full class)
     
  5. Offline

    WitchCraftMC

    There are no errors or warnings but I will try your advice thanks :D and I cant give out full class because its a top secret plugin :D I can give the onEnable

    I dont know what A stack trace is. If u could tell me that would be amazing :D

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

    Forseth11

    When you run it, it is the error that comes up that basically tells you where the problem is. Do you get any errors?
     
  7. Offline

    WitchCraftMC

    There is no errors.

    Dubehh
    When I put the Scoreboard + Teams into the onEnable it gives me a error under were it says red.addPlayer(player) and player.sendMessage(ChatColor.GREEN + "" + ChatColor.BOLD + "Successfully Created Teams! ") any hint?

    Dubehh

    I tried puting it in the onEnable but that didnt work :( any other ideas? :rolleyes:

    Gonna be eating dinner wont be back until 1 hour max 15 minimum :)

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

    Dubehh

    WitchCraftMC
    Yes, I didn't mean putting your code directly into the onEnable method.
    Code:java
    1. public class something extends JavaPlugin{
    2. ScoreboardManager manager; //Field
    3. Scoreboard board; //Field
    4. Objective obj; //Field
    5.  
    6. public void onEnable(){
    7. loadScoreboard(); //Load up the method in the onEnable
    8. }
    9.  
    10. public void loadScoreboard(){ //Actually define the fields (Else errors)
    11. manager = Bukkit.getScoreboardManager();
    12. board = manager.getNewScoreboard();
    13. obj = board.registerNewObjective("Something", "Something");
    14. }
    15.  
    16. onCommand(Something, Something){ //On the command
    17. if(command.equalsIgnorecase("SomeCommand")){
    18. Team red = board.registerNewTeam("Red");
    19. Team blue = board.registerNewTeam("Blue");


    I am not entirely sure if that's the problem, because I always load up my scoreboard in the onEnable() method.
    For the "Omg stop spoonfedding" people: I did not write the entire work for him, nor did I went close to that. This is just a way in a direction (Might be a wrong direction lol)
    For the OP: Your 'top secret' should be public if you want actual help for it.

    If you aren't able to create a scoreboard, I doubt there are people who steal your code.
    (no offense)
     
  9. Offline

    WitchCraftMC

    Ok thanks for the advice :)

    Dubehh. I dont know were to put the code.... Im kinda lost.

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

    Dubehh

    WitchCraftMC
    What are you trying to achieve?
    Do you want to add players to a certain team on a command?
    Or do you actually want to 'just' create teams on a command, because wouldn't it be easier to create teams in the beginning and add players later on? I don't see an actual use to just create two teams without doing something with em
     
  11. Offline

    WitchCraftMC

    Dubehh Yeah I was just trying to create teams then add them later
     
  12. Offline

    Dubehh

    WitchCraftMC

    Use what I earlier said, from loading the scoreboard in the onEnable(),

    Code:java
    1. public void loadTeams(){ //Make a method
    2. red = board.registerNewTeam("red");
    3. blue = board.registerNewTeam("blue");
    4. //Add some options here for both of the teams
    5. //Add the 'LoadTeams()' method to the onEnable()
    6.  
    7. //On your command boolean thing, just add
    8. red.addPlayer(playerThatTypedACommand);
    9.  
     
  13. Offline

    WitchCraftMC

Thread Status:
Not open for further replies.

Share This Page