title: Player should be able to create their own team and can invite people to it
body: <p>Basically p sends a invite to the team to p2. p2 joins p's team which is generated but it won't let them leave and it is really buggy is there an easier way to set it up so the player creates the team and invites them to the team and can destroy the team?</p>
  
  <pre><code>/*
   *
   * 
   * @author Demon Dylan001 &lt;gigantedylan001@yahoo.com&gt;
   * 
   */
  
  public final class test {
  
  private static String Leader;
  private static String LeaderDisplayName;
      List&lt;String&gt; teams = new ArrayList&lt;String&gt;();
  private static HashMap&lt;String, Assault&gt; AssaultTeams;
  public static CopyOnWriteArrayList&lt;Player&gt; players; 
  public static int attackerlvl = 1;
  public static int defenderlvl = 1;
  public static int healerlvl = 1;
  public static int collectorlvl = 1;
  public static boolean hasRole = false;
  public static boolean attacker = false;
  public static boolean defender = false;
  public static boolean healer = false;
  public static boolean collector = false;
  public static boolean extra = false;    
  
  private final Player p, p2;
  
  /**
   * Constructor
   * 
   * @param p
   * @param p2
   */
  public Assault(Player p, Player p2) {
      Leader = p.getUsername();
      LeaderDisplayName = p.getDisplayName();
      players = new CopyOnWriteArrayList&lt;Player&gt;();
      this.p = p;
      this.p2 = p2;
      }
  
  
  public static void init() {
      AssaultTeams = new HashMap&lt;String, Assault&gt;();
  }
  public void start() {
      SendAssaultRequest(p);
      SendAssaultRequest(p2);
  }
  public CopyOnWriteArrayList&lt;Player&gt; getPlayers() {
      return players;
  }
  
  public String getLeaderDisplayName() {
      return LeaderDisplayName;
  }
  
  public String getLeaderName() {
      return Leader;
  }
  
  public void SendAssaultRequest(Player player) {
          p.getInterfaceManager().sendInterface(492);
          p2.getInterfaceManager().sendInterface(493);
          player.getPackets().sendIComponentText(492, 1, "Player 1 Interface Screen");
          player.getPackets().sendIComponentText(492, 2, "Decline");
          player.getPackets().sendIComponentText(492, 4, "Accept");
          player.getPackets().sendIComponentText(492, 7, "The Team:");
          player.getPackets().sendIComponentText(492, 8, "Name");
          player.getPackets().sendIComponentText(492, 9, "Role");
          player.getPackets().sendIComponentText(492, 15, "player 1");
          player.getPackets().sendIComponentText(492, 16, "player 2");
          player.getPackets().sendIComponentText(492, 17, "player 3");
          player.getPackets().sendIComponentText(492, 18, "player 4");
          player.getPackets().sendIComponentText(492, 19, "player 5");
          player.getPackets().sendIComponentText(492, 20, "" + getRole());
          player.getPackets().sendIComponentText(492, 21, "" + getRole());
          player.getPackets().sendIComponentText(492, 22, "" + getRole());
          player.getPackets().sendIComponentText(492, 23, "" + getRole());
          player.getPackets().sendIComponentText(492, 24, "" + getRole());
          player.getPackets().sendIComponentText(492, 25, "Wave:");
          player.getPackets().sendIComponentText(492, 30, "Remove");
          player.getPackets().sendIComponentText(493, 1, "1");
          player.getPackets().sendIComponentText(493, 2, "2");
          player.getPackets().sendIComponentText(493, 3, "3");
          player.getPackets().sendIComponentText(493, 4, "4");
          player.getPackets().sendIComponentText(493, 5, "Player 2 Interface Screen");
          player.getPackets().sendIComponentText(493, 6, "Decline");
          player.getPackets().sendIComponentText(493, 7, "7");
          player.getPackets().sendIComponentText(493, 8, "Attacker");
          player.getPackets().sendIComponentText(493, 9, "9");
          player.getPackets().sendIComponentText(493, 10, "Defender");
          player.getPackets().sendIComponentText(493, 11, "Collector");
          player.getPackets().sendIComponentText(493, 12, "12");
          player.getPackets().sendIComponentText(493, 13, "13");
          player.getPackets().sendIComponentText(493, 14, "Healer");
          player.getPackets().sendIComponentText(493, 15, "15");
          player.getPackets().sendIComponentText(493, 16, "Accept");
          player.getPackets().sendIComponentText(493, 17, "17");
          player.getPackets().sendIComponentText(493, 18, "" + p2.getAssault().getRole());
          player.getPackets().sendIComponentText(493, 19, "19");
          player.getPackets().sendIComponentText(493, 20, "20");
          player.getPackets().sendIComponentText(493, 21, "" + hasSelected());
          player.getPackets().sendIComponentText(493, 22, "The Team:");
          player.getPackets().sendIComponentText(493, 23, "Name:");
          player.getPackets().sendIComponentText(493, 24, "Role:");
          player.getPackets().sendIComponentText(493, 25, "---Leader---");
          player.getPackets().sendIComponentText(493, 26, "---Followers---");
          player.getPackets().sendIComponentText(493, 27, "27");
          player.getPackets().sendIComponentText(493, 28, "28");
          player.getPackets().sendIComponentText(493, 29, "29");
          player.getPackets().sendIComponentText(493, 30, "30");
          player.getPackets().sendIComponentText(493, 31, "31");
          player.getPackets().sendIComponentText(493, 32, "none set");
  }
  
      public boolean checkSelect(Player player) {
      return true;
  }
  
  public void updateSelect() {
  p.getPackets().sendIComponentText(492, 5, "" + p2.getAssault().getRole());
  p.getPackets().sendIComponentText(492, 6, "" + p2.getAssault().getRolelvl());
  p2.getPackets().sendIComponentText(493, 18, "" + p2.getAssault().getRole());
  }
      public int getattacker() {
      return attackerlvl;
  }
      public int getdefender() {
      return defenderlvl;
  }
      public int gethealer() {
      return healerlvl;
  }
      public int getcollector() {
      return collectorlvl;
  }
  public int getRolelvl() {
  if (defender)
  return getdefender();
  else if (healer)
  return gethealer();
  else if (attacker)
  return getattacker();
  else if (collector)
  return getcollector();
  return 5;
  }
  public static String getRole() {
  String roleId = "";
  if (defender)
  return roleId = "Defender";
  if (healer)
  return roleId = "Healer";
  if (attacker)
  return roleId = "Attacker";
  if (collector)
  return roleId = "Collector";
  return "Nothing";
  }
      public String hasSelected() {
      return "Please Select a Role";
  }
  
      public static void PassThroughBarrier(Player player) {
          if (player.getX() == 2578 &amp;&amp; player.getY() == 5294) {
          player.addWalkSteps(2578, 5295, player.getPlane(), false);
          EnterWaitingRoom(player);
          player.getPackets().sendGameMessage(
                  "You enter the Barbarian Assault Waitng room", true);
      } else {
          player.addWalkSteps(2578, 5294, player.getPlane(), false);
          LeaveWaitingRoom(player);
          player.getPackets().sendGameMessage(
                  "You left the Barbarian Assault Waitng room", true);
  }
  
  }
  
      public static void EnterWaitingRoom(Player player) {
      player.isinAssault = true;
  }
  
      public static void LeaveWaitingRoom(Player player) {
      player.isinAssault = false;
      player.getPackets().sendGameMessage("You leave your barbarian assault team.", true);
      synchronized (AssaultTeams) {
      player.setCurrentAssault(null);
      players.remove(player);
      player.hasTeam = false;
      if (players.size() == 0) {
          synchronized (AssaultTeams) {
          AssaultTeams.remove(Leader);
          }
      }
  }
  }
  
      public static void startgame(Player player) {
          if (Assault.players.size() &lt; 4) {
              player.getPackets().sendGameMessage("You need at least 4 teamates.");
              return;
          }
          if (player.hasTeam == false) {
              player.getPackets().sendGameMessage("You must be on a team to go down there.");
              return;
          }
  
  }
  
  public static boolean handleObjects(Player player, int objectId) {
      if (objectId == 20149) {
          if (player.getInventory().containsItem(10512, 1)) {
          player.getPackets().sendGameMessage(
                  "You already have a scroll", true);
          } else {
          player.getInventory().addItem(10512, 1);
          player.getPackets().sendGameMessage(
                  "You have obtained a scroll", true);
          }
          return true;
      } else if (objectId == 20199) {
          PassThroughBarrier(player);
          return true;
      } else if (objectId == 20193) {
          startgame(player);
          return true;
      }
      return false;
  }
  public static boolean isInAssault(Player player) {
      return player.getX() &gt;= 2574 &amp;&amp; player.getY() &gt;= 5295
              &amp;&amp; player.getX() &lt;= 2583 &amp;&amp; player.getY() &lt;= 5308;
  }
  
  public void handleDecline() {
      p2.clearRoles();
      p.accepted = false;
      p2.accepted = false;
      p.closeInterfaces();
      p2.closeInterfaces();
  }
  
  public void handleAccept() {
      if (p.accepted == true &amp;&amp; p2.accepted == false) {
          p.getPackets().sendGameMessage(p2.getUsername() + " has not accepted yet", true);
          return;
      } else if (p2.accepted == true &amp;&amp; p.accepted == false) {
          p2.getPackets().sendGameMessage(p2.getUsername() + " has not accepted yet", true);
          return;
      } else {
      synchronized (this) {
      p.closeInterfaces();
      p2.closeInterfaces();
      p.accepted = false;
      p2.accepted = false;
      players.add(p2);
      p2.hasTeam = true;
      p2.setCurrentAssault(this);
      p2.setCurrentAssaultLeader(Leader);
      //refreshLobbyinter();
      }
  }
  }
  private void refreshLobbyinter() {
      synchronized (this) {
      }
  }
  public void makeAttacker() {
  p2.clearRoles();
  hasRole = true;
  attacker = true;
  p.getPackets().sendGameMessage(p2.getUsername() + " has chosen to be a attacker.", true);
  p2.getPackets().sendGameMessage("You have chosen to be a attacker.", true);
  updateSelect();
  }
  
  public void makeDefender() {
  p2.clearRoles();
  hasRole = true;
  defender = true;
  p.getPackets().sendGameMessage(p2.getUsername() + " has chosen to be a defender.", true);
  p2.getPackets().sendGameMessage("You have chosen to be a defender.", true);
  updateSelect();
  }
  
  public void makeHealer() {
  p2.clearRoles();
  hasRole = true;
  healer = true;
  p.getPackets().sendGameMessage(p2.getUsername() + " has chosen to be a healer.", true);
  p2.getPackets().sendGameMessage("You have chosen to be a healer.", true);
  updateSelect();
  }
  
  public void makeCollector() {
  p2.clearRoles();
  hasRole = true;
  collector = true;
  p.getPackets().sendGameMessage(p2.getUsername() + " has chosen to be a collector.", true);
  p2.getPackets().sendGameMessage("You have chosen to be a collector.", true);
  updateSelect();
  }
  
  public void handleAssault(int interfaceId, int componentId) {
      if (interfaceId == 492) {
          if (componentId == 35) { //accept
          p.accepted = true;
          handleAccept();
          p.accepted = true;
          } else if (componentId == 3) { //decline
          handleDecline();
          p2.getPackets().sendGameMessage(p.getUsername() + " has declined.", true);
          p.getPackets().sendGameMessage("You have declined.", true);
              }
          } else if (interfaceId == 493) {
          if (componentId == 7)//attacker
          makeAttacker();
          else if (componentId == 9)//defender
          makeDefender();
          else if (componentId == 12)//collector
          makeCollector();
          else if (componentId == 13)//healer
          makeHealer();
          else if (componentId == 15) { //accept
          p2.accepted = true;
          handleAccept();
          } else if (componentId == 17) { //decline
          handleDecline();
          p.getPackets().sendGameMessage(p2.getUsername() + " has declined.", true);
          p2.getPackets().sendGameMessage("You have declined.", true);
          }
      }
  }
  }
  </code></pre>