public void leave(PartyMember member) { if (hasMember(member)) { if ((member.isLeader()) && (this.members.size() > 1)) { Random rand = new Random(); PartyMember newLeader = null; while ((newLeader == null) || (newLeader == member)) { newLeader = (PartyMember) this.members.get(rand.nextInt(this.members.size())); } if (newLeader != null) { PartyController.instance() .promoteMember( PartyController.instance().getMember(newLeader.username), MemberType.LEADER, true); } } this.members.remove(member); if (this.members.size() <= 0) { PartyController.instance().removeParty(this, true); } } }
public void join(PartyMember member) { if ((member != null) && (this.members.size() < this.memberSizeLimit) && (!hasMember(member))) { Party party; if (PartyController.instance().inParty(member.username)) { party = PartyController.instance() .getParty(PartyController.instance().getMember(member.username)); } if (isRequestedPlayer(member.username)) { removeRequestedPlayer(member.username); } this.members.add(member); } }