Solved Arraylist to scoreboard teams?

Discussion in 'Plugin Development' started by robbertie, Nov 13, 2013.

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


    I have a question because I am making a minigame plugin.. and I have made a lobby so when the players join they are put in a arraylist and then they see a countdown.. but I want to make that when the countdown has finished the players are put in 2 different scoreboard teams.. how do I make this?


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


    You would go through each player in your arraylist i'm thinking. Here is an example.
    1. for (Player p : Arraylist.getPlayers //Not sure about Arraylist.getPlayers){
    2. if(redteam < blueteam){ //For example red and blue team.
    3. redteam.addPlayer(p);
    4. }else{
    5. blueteam.addPlayer(p);
    6. }
    7. } //I didnt test this code i just thought of it but it should work.
  3. Offline


    markieo it isnt working.. Any other ideas I get a nullpointer exception and I already fixed Arraylist.getPlayers

    Ok maybe I have to register the teams hmmm lets do that

    Teams doesnt work at all any help appreciated???????

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


    Okay, for us to be able to help you need to post your code, the error you're getting, and the line of code that the error is pointing to.
  5. Offline


    red = boardGame.registerNewTeam("red");
    blue = boardGame.registerNewTeam("blue");
    red.setPrefix(ChatColor.RED + "");
    blue.setPrefix(ChatColor.BLUE + "");

    It doesnt do anything and it gives me a nullpointer.. russjr08
  6. Offline


    What line of code gives you the nullpointer?
  7. Offline


    It doesnt give me an error anymore but it still doesnt work.. russjr08
  8. Offline


    Well post your code then. Not just five lines of it, we can't tell anything from that.
  9. Offline


    My onEnable is:

    1. obg = boardGame.registerNewObjective("Game", "dummy");
    2. obg.setDisplayName(ChatColor.GOLD + "Game info: ");
    3. obg.setDisplaySlot(DisplaySlot.SIDEBAR);
    4. s2 = obg.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "TEST: "));
    5. s2.setScore(50);
    6. red = boardGame.registerNewTeam("red");
    7. blue = boardGame.registerNewTeam("blue");
    8. red.addPlayer(Bukkit.getOfflinePlayer("robbertie"));
    9. red.setPrefix(ChatColor.RED + "");
    10. blue.setPrefix(ChatColor.BLUE + "");

    And my runnable is:

    1. for(String name : Hub.alp){
    2. Player player = Bukkit.getServer().getPlayerExact(name);
    3. player.sendMessage(ChatColor.GREEN + "GO!");
    4. player.setScoreboard(Hub.boardGame);
    5. player.teleport(new Location(player.getWorld(), Hub.gamex, Hub.gamey, Hub.gamez, Hub.gameyaw, 0));
    7. }
    8. Hub.alp.clear();
    9. Hub.countdownmini = 20;
    10. Hub.countdownhead = 1;
    11. Hub.isRunning = false;
    12. Bukkit.getScheduler().cancelTask(taskID);

    Garris0n & russjr08

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


  11. Offline


    Paste your entire class. That still doesn't help..
  12. Offline


    Nevermind I am not coming that far with this help and why do I have to paste the hole class? So you can copy it?
  13. Offline


    I don't want to copy it.. You were the one that came on here asking for help and I'm just trying to help you.
    TigerHix likes this.
  14. Offline


    Ok nevermind I already fixed it.
  15. Offline


    Please set the thread to solved.

    There isn't a need to be paranoid. We need to see the code to help you. It's not "copying" if we see your code. Besides, drtshock is devBukkit staff, I'm pretty sure he knows how to code all of this himself. There are probably other resources if we truly wished to "copy" your work.
    TigerHix likes this.
  16. Offline


Thread Status:
Not open for further replies.

Share This Page