Ejemplo n.º 1
0
 public HeroParty find(String player) {
   for (HeroParty party : hplugin.getPartyManager().getParties()) {
     if (party.getMembers().contains(player)) {
       return party;
     }
   }
   HeroParty party =
       new HeroParty(
           hplugin.getCharacterManager().getHero(this.getServer().getPlayer(player)), hplugin);
   hplugin.getPartyManager().addParty(party);
   return party;
 }
Ejemplo n.º 2
0
  public static ArenaTeam getTeam(Player player) {
    Hero hero = getHero(player);
    if (hero == null) return null;
    HeroParty party = hero.getParty();
    if (party == null) return null;
    ArenaTeam t = TeamFactory.createCompositeTeam();
    Hero leader = party.getLeader();
    if (leader != null) t.addPlayer(BattleArena.toArenaPlayer(leader.getPlayer()));

    Set<Hero> members = party.getMembers();
    if (members != null) {
      for (Hero h : members) {
        t.addPlayer(BattleArena.toArenaPlayer(h.getPlayer()));
      }
    }
    return t.size() > 0 ? t : null;
  }
Ejemplo n.º 3
0
  public static void addedToTeam(ArenaTeam team, Player player) {
    HeroParty party = parties.get(team);
    if (party == null) party = createTeam(team);

    Hero hero = getHero(player);
    if (hero == null) return;

    removeOldParty(hero, party);

    if (party == null) {
      party = createParty(team, hero);
    }

    /// Add the hero to the party,
    /// and the tell the hero which party they are in
    party.addMember(hero);
    hero.setParty(party);
  }
Ejemplo n.º 4
0
  public static HeroParty createTeam(ArenaTeam team) {
    HeroParty party = null;
    for (ArenaPlayer player : team.getPlayers()) {
      Hero hero = getHero(player.getPlayer());
      if (hero == null) continue;

      removeOldParty(hero, null); // / Remove from any old parties
      /// if the party doesnt exist create it
      if (party == null) {
        party = createParty(team, hero);
      }
      /// Add the hero to the party,
      /// and the tell the hero which party they are in
      party.addMember(hero);
      hero.setParty(party);
    }
    return party;
  }
Ejemplo n.º 5
0
 public void update(HeroParty hp) {
   for (Hero player : hp.getMembers()) {
     update(player.getPlayer());
   }
 }
Ejemplo n.º 6
0
 private static void removeOldParty(Hero hero, HeroParty newParty) {
   HeroParty party = hero.getParty();
   if (party == null || (newParty != null && newParty == party)) return;
   party.removeMember(hero);
   hero.setParty(null);
 }