private static final void renameSubPledge( L2PcInstance player, int pledgeType, String pledgeName) { if (!player.isClanLeader()) { player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT)); return; } final L2Clan clan = player.getClan(); final SubPledge subPledge = player.getClan().getSubPledge(pledgeType); if (subPledge == null) { player.sendMessage("Pledge don't exists."); return; } if (!Util.isAlphaNumeric(pledgeName) || 2 > pledgeName.length()) { player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_INCORRECT)); return; } if (pledgeName.length() > 16) { player.sendPacket(new SystemMessage(SystemMessageId.CLAN_NAME_TOO_LONG)); return; } subPledge.setName(pledgeName); clan.updateSubPledgeInDB(subPledge.getId()); clan.broadcastClanStatus(); player.sendMessage("Pledge name changed."); }
private static final void createSubPledge( L2PcInstance player, String clanName, String leaderName, int pledgeType, int minClanLvl) { if (!player.isClanLeader()) { player.sendPacket(new SystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT)); return; } final 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; } } final int leaderId = pledgeType != L2Clan.SUBUNIT_ACADEMY ? clan.getClanMember(leaderName).getObjectId() : 0; if (clan.createSubPledge(player, pledgeType, leaderId, 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) { final L2ClanMember leaderSubPledge = clan.getClanMember(leaderName); final L2PcInstance leaderPlayer = leaderSubPledge.getPlayerInstance(); if (leaderPlayer != null) { leaderPlayer.setPledgeClass(leaderSubPledge.calculatePledgeClass(leaderPlayer)); leaderPlayer.sendPacket(new UserInfo(leaderPlayer)); leaderPlayer.sendPacket(new ExBrExtraUserInfo(leaderPlayer)); } } }
@Override protected void runImpl() { // Last Verified: May 30, 2009 - Gracia Final - Players are able to create characters with names // consisting of as little as 1,2,3 letter/number combinations. if ((_name.length() < 1) || (_name.length() > 16)) { if (Config.DEBUG) _log.fine( "Character Creation Failure: Character name " + _name + " is invalid. Message generated: Your title cannot exceed 16 characters in length. Please try again."); sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS)); return; } if (Config.FORBIDDEN_NAMES.length > 1) { for (String st : Config.FORBIDDEN_NAMES) { if (_name.toLowerCase().contains(st.toLowerCase())) { sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME)); return; } } } // Last Verified: May 30, 2009 - Gracia Final if (!Util.isAlphaNumeric(_name) || !isValidName(_name)) { if (Config.DEBUG) _log.fine( "Character Creation Failure: Character name " + _name + " is invalid. Message generated: Incorrect name. Please try again."); sendPacket(new CharCreateFail(CharCreateFail.REASON_INCORRECT_NAME)); return; } if (_face > 2 || _face < 0) { _log.warning( "Character Creation Failure: Character face " + _face + " is invalid. Possible client hack. " + getClient()); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } if (_hairStyle < 0 || (_sex == 0 && _hairStyle > 4) || (_sex != 0 && _hairStyle > 6)) { _log.warning( "Character Creation Failure: Character hair style " + _hairStyle + " is invalid. Possible client hack. " + getClient()); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } if (_hairColor > 3 || _hairColor < 0) { _log.warning( "Character Creation Failure: Character hair color " + _hairColor + " is invalid. Possible client hack. " + getClient()); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } L2PcInstance newChar = null; L2PcTemplate template = null; /* * DrHouse: Since checks for duplicate names are done using SQL, lock must be held until data is written to DB as well. */ synchronized (CharNameTable.getInstance()) { if (CharNameTable.getInstance().accountCharNumber(getClient().getAccountName()) >= Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT && Config.MAX_CHARACTERS_NUMBER_PER_ACCOUNT != 0) { if (Config.DEBUG) _log.fine("Max number of characters reached. Creation failed."); sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS)); return; } else if (CharNameTable.getInstance().doesCharNameExist(_name)) { if (Config.DEBUG) _log.fine( "Character Creation Failure: Message generated: You cannot create another character. Please delete the existing character and try again."); sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS)); return; } template = CharTemplateTable.getInstance().getTemplate(_classId); if (template == null || template.classBaseLevel > 1) { if (Config.DEBUG) _log.fine( "Character Creation Failure: " + _name + " classId: " + _classId + " Template: " + template + " Message generated: Your character creation has failed."); sendPacket(new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED)); return; } int objectId = IdFactory.getInstance().getNextId(); newChar = L2PcInstance.create( objectId, template, getClient().getAccountName(), _name, _hairStyle, _hairColor, _face, _sex != 0); } newChar.setCurrentHp(template.baseHpMax); newChar.setCurrentCp(template.baseCpMax); newChar.setCurrentMp(template.baseMpMax); // newChar.setMaxLoad(template.baseLoad); CharCreateOk cco = new CharCreateOk(); sendPacket(cco); initNewChar(getClient(), newChar); LogRecord record = new LogRecord(Level.INFO, "Created new character"); record.setParameters(new Object[] {newChar, this.getClient()}); _logAccounting.log(record); }