BattleArenaAPI getting Teams

Discussion in 'Plugin Development' started by Tcfox, Aug 4, 2014.

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

    Tcfox

    I hope this problem is not to specific for you guys to help me out, but basically this is the code I've got:

    Code:
    public void onStart(){
            List<ArenaTeam> teams = getTeams();
            for(ArenaTeam name : getTeams()){
                int i=1;
                Bukkit.broadcastMessage("" + name);
                nexusTeams.put(i, name.getIDString());
                Bukkit.broadcastMessage(""+i);
                i = i+1;
            }
            Bukkit.broadcastMessage(""+nexusTeams.size());
            Bukkit.broadcastMessage(nexusTeams.get(1));
            Bukkit.broadcastMessage(nexusTeams.get(2));
     
        }

    And this is the Result that I get in Terminal:

    [19:31:16 INFO]: [Foxycs]
    [19:31:16 INFO]: 1
    [19:31:16 INFO]: [fixiifcs]
    [19:31:16 INFO]: 1
    [19:31:16 INFO]: 1
    [19:31:16 INFO]: 4

    [19:31:16 WARN]: java.lang.NullPointerException
    What i want to do is get the separate team names and change them to simple "Blue Team" and "Red Team" then ill be able to retrieve them at a later time from a the hashmap. If there is a better way to do this I'm all for it. Im really new at this and I'm using a giant API that i don't completely understand so any help would be GREAT!
    Thanks
     
  2. Offline

    masons123456

    Tcfox First off, move your variable "i" outside of the loop because it resets to 1 every time. Also, Lists and HashMaps usually start at 0 instead of 1. Finally, you might just be able to replace "i" with just getTeams().indexOf(name)
     
  3. Offline

    Tcfox

    Thanks dude, but I actually eventually figured something else out and forgot about this thread.
    Code:
    public void onStart(){// Sets up the teams, (add tower locs and boundaries)
            List<ArenaTeam> t = getTeams();
            for (int i = 0; i < t.size(); i++) {
                Bukkit.broadcastMessage(""+t.get(i));
                if(i==0){
                    ArenaTeam team1 = t.get(i);
                    team1.setName("Red");
                }
                else if(i==1){
                    ArenaTeam team2 = t.get(i);
                    team2.setName("Blue");
                }
            }
        }
     
Thread Status:
Not open for further replies.

Share This Page