Package com.l2jfrozen.gameserver.network.serverpackets

Examples of com.l2jfrozen.gameserver.network.serverpackets.CharCreateFail


    if (_name.length() < 3 || _name.length() > 16 || !Util.isAlphaNumeric(_name) || !isValidName(_name))
    {
      if (Config.DEBUG)
        _log.fine("DEBUG "+getType()+": charname: " + _name + " is invalid. creation failed.");

      sendPacket(new CharCreateFail(CharCreateFail.REASON_16_ENG_CHARS));
      return;
    }

    if (Config.DEBUG)
      _log.fine("DEBUG "+getType()+": charname: " + _name + " classId: " + _classId);

    L2PcInstance newChar = null;
    L2PcTemplate template = null;

    // 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("DEBUG "+getType()+": 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("DEBUG "+getType()+": charname: " + _name + " already exists. creation failed.");

        sendPacket(new CharCreateFail(CharCreateFail.REASON_NAME_ALREADY_EXISTS));
        return;
      }else if (CharNameTable.getInstance().ipCharNumber(getClient().getConnection().getInetAddress().getHostName()) >= Config.MAX_CHARACTERS_NUMBER_PER_IP && Config.MAX_CHARACTERS_NUMBER_PER_IP != 0)
      {
        if (Config.DEBUG)
          _log.fine("DEBUG "+getType()+": Max number of characters reached for IP. Creation failed.");
       
        sendPacket(new CharCreateFail(CharCreateFail.REASON_TOO_MANY_CHARACTERS));
        return;
      }

      template = CharTemplateTable.getInstance().getTemplate(_classId);

      if (Config.DEBUG)
        _log.fine("DEBUG "+getType()+": charname: " + _name + " classId: " + _classId + " template: " + template);

      if (template == null || template.classBaseLevel > 1)
      {
        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);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.network.serverpackets.CharCreateFail

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.