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; }
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; }
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); }
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; }
public void update(HeroParty hp) { for (Hero player : hp.getMembers()) { update(player.getPlayer()); } }
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); }