leader.setParty(party);
player.setParty(party);
this don't needed on code
on new Party(leader, _players.get(1), LootRule.ITEM_RANDOM);
they set leader.setParty(party);
and on party.addPartyMember(player); has set for player.setParty(party);
this method can create max 1 party
because new party is up of for
try this
// create party players
public void createPartyOfTeam(int teamId)
{
final List<PcInstance> _players = new ArrayList<>();
for (PcInstance p : players.keySet())
{
if (getTeam(p) == teamId)
{
if (p.isInParty())
p.getParty().removePartyMember(p, MessageType.EXPELLED);
_players.add(p);
}
}
int i = 0;
PcInstance leader = null;
Party party = null;
for (PcInstance player : _players)
{
if (i == 0)
leader = player;
else if (i == 1 || party == null)
party = new Party(leader, player, LootRule.ITEM_RANDOM);
else if (i < 9)
party.addPartyMember(player);
else
{
i = 0;
leader = player;
}
i++;
}
}