{
if (!(requestor.getRequest().getRequestPacket() instanceof RequestJoinPledge))
return; // hax
RequestJoinPledge requestPacket = (RequestJoinPledge) requestor.getRequest().getRequestPacket();
L2Clan clan = requestor.getClan();
// we must double check this cause during response time conditions can be changed, i.e. another player could join clan
if (clan != null && clan.checkClanJoinCondition(requestor, activeChar, requestPacket.getPledgeType()))
{
JoinPledge jp = new JoinPledge(requestor.getClanId());
activeChar.sendPacket(jp);
activeChar.setPledgeType(requestPacket.getPledgeType());
if (requestPacket.getPledgeType() == L2Clan.SUBUNIT_ACADEMY)
{
activeChar.setPowerGrade(9); // adademy
activeChar.setLvlJoinedAcademy(activeChar.getLevel());
}
else
{
activeChar.setPowerGrade(5); // new member starts at 5, not confirmed
}
clan.addClanMember(activeChar);
activeChar.setClanPrivileges(activeChar.getClan().getRankPrivs(activeChar.getPowerGrade()));
activeChar.sendPacket(new SystemMessage(SystemMessageId.ENTERED_THE_CLAN));
SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_JOINED_CLAN);
sm.addString(activeChar.getName());
clan.broadcastToOnlineMembers(sm);
clan.broadcastToOtherOnlineMembers(new PledgeShowMemberListAdd(activeChar), activeChar);
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
// this activates the clan tab on the new member
activeChar.sendPacket(new PledgeShowMemberListAll(clan, activeChar));
activeChar.setClanJoinExpiryTime(0);
activeChar.broadcastUserInfo();