{
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.");
CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS);
sendPacket(ccf);
return;
}
else if (CharNameTable.getInstance().doesCharNameExist(_name))
{
if (Config.DEBUG)
_log.fine("charname: "+ _name + " already exists. creation failed.");
CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS);
sendPacket(ccf);
return;
}
else if ((_name.length() < 3) || (_name.length() > 16) || !Util.isAlphaNumeric(_name) || !isValidName(_name))
{
if (Config.DEBUG)
_log.fine("charname: " + _name + " is invalid. creation failed.");
CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS);
sendPacket(ccf);
return;
}
if (Config.DEBUG)
_log.fine("charname: " + _name + " classId: " + _classId);
L2PcTemplate template = CharTemplateTable.getInstance().getTemplate(_classId);
if(template == null || template.classBaseLevel > 1)
{
CharCreateFail ccf = new CharCreateFail(CharCreateFail.REASON_CREATION_FAILED);
sendPacket(ccf);
return;
}
int objectId = IdFactory.getInstance().getNextId();