{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT));
return;
}
L2Clan clan = player.getClan();
if(clan.getLevel() < minClanLvl)
{
if(pledgeType == L2Clan.SUBUNIT_ACADEMY)
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_DO_NOT_MEET_CRITERIA_IN_ORDER_TO_CREATE_A_CLAN_ACADEMY));
}
else
{
player.sendPacket(new SystemMessage(SystemMessageId.YOU_DO_NOT_MEET_CRITERIA_IN_ORDER_TO_CREATE_A_MILITARY_UNIT));
}
return;
}
if(!Util.isAlphaNumeric(clanName) || 2 > clanName.length())
{
player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT));
return;
}
if(clanName.length() > 16)
{
player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_TOO_LONG));
return;
}
for(L2Clan tempClan : ClanTable.getInstance().getClans())
{
if(tempClan.getSubPledge(clanName) != null)
{
if(pledgeType == L2Clan.SUBUNIT_ACADEMY)
{
SystemMessage sm = new SystemMessage(SystemMessageId.S1_ALREADY_EXISTS);
sm.addString(clanName);
player.sendPacket(sm);
sm = null;
}
else
{
player.sendPacket(new SystemMessage(SystemMessageId.ANOTHER_MILITARY_UNIT_IS_ALREADY_USING_THAT_NAME));
}
return;
}
}
if(pledgeType != L2Clan.SUBUNIT_ACADEMY)
if(clan.getClanMember(leaderName) == null || clan.getClanMember(leaderName).getPledgeType() != 0)
{
if(pledgeType >= L2Clan.SUBUNIT_KNIGHT1)
{
player.sendPacket(new SystemMessage(SystemMessageId.CAPTAIN_OF_ORDER_OF_KNIGHTS_CANNOT_BE_APPOINTED));
}
else if(pledgeType >= L2Clan.SUBUNIT_ROYAL1)
{
player.sendPacket(new SystemMessage(SystemMessageId.CAPTAIN_OF_ROYAL_GUARD_CANNOT_BE_APPOINTED));
}
return;
}
if(clan.createSubPledge(player, pledgeType, leaderName, clanName) == null)
return;
SystemMessage sm;
if(pledgeType == L2Clan.SUBUNIT_ACADEMY)
{
sm = new SystemMessage(SystemMessageId.THE_S1S_CLAN_ACADEMY_HAS_BEEN_CREATED);
sm.addString(player.getClan().getName());
}
else if(pledgeType >= L2Clan.SUBUNIT_KNIGHT1)
{
sm = new SystemMessage(SystemMessageId.THE_KNIGHTS_OF_S1_HAVE_BEEN_CREATED);
sm.addString(player.getClan().getName());
}
else if(pledgeType >= L2Clan.SUBUNIT_ROYAL1)
{
sm = new SystemMessage(SystemMessageId.THE_ROYAL_GUARD_OF_S1_HAVE_BEEN_CREATED);
sm.addString(player.getClan().getName());
}
else
{
sm = new SystemMessage(SystemMessageId.CLAN_CREATED);
}
player.sendPacket(sm);
if(pledgeType != L2Clan.SUBUNIT_ACADEMY)
{
L2ClanMember leaderSubPledge = clan.getClanMember(leaderName);
if(leaderSubPledge.getPlayerInstance() == null)
return;
leaderSubPledge.getPlayerInstance().setPledgeClass(leaderSubPledge.calculatePledgeClass(leaderSubPledge.getPlayerInstance()));
leaderSubPledge.getPlayerInstance().sendPacket(new UserInfo(leaderSubPledge.getPlayerInstance()));