/** {@inheritDoc} */
  @Override
  protected void writeImpl(AionConnection con, ByteBuffer buf) {
    Account account = con.getAccount();

    writeD(buf, ok ? 0x00 : 0x01);
    writeS(buf, account.getName());
  }
Ejemplo n.º 2
0
  /**
   * Returns the player with given objId (if such player exists)
   *
   * @param playerObjId
   * @param account
   * @return Player
   */
  public static Player getPlayer(int playerObjId, Account account) {
    Player player = playerCache.get(playerObjId);
    if (player != null) return player;

    /** Player common data and appearance should be already loaded in account */
    PlayerAccountData playerAccountData = account.getPlayerAccountData(playerObjId);
    PlayerCommonData pcd = playerAccountData.getPlayerCommonData();
    PlayerAppearance appearance = playerAccountData.getAppereance();

    player = new Player(new PlayerController(), pcd, appearance, account);

    LegionMember legionMember = LegionService.getInstance().getLegionMember(player.getObjectId());
    if (legionMember != null) player.setLegionMember(legionMember);

    MacroList macroses = DAOManager.getDAO(PlayerMacrossesDAO.class).restoreMacrosses(playerObjId);
    player.setMacroList(macroses);

    player.setSkillList(DAOManager.getDAO(PlayerSkillListDAO.class).loadSkillList(playerObjId));
    player.setKnownlist(new KnownList(player));
    player.setFriendList(DAOManager.getDAO(FriendListDAO.class).load(player));
    player.setBlockList(DAOManager.getDAO(BlockListDAO.class).load(player));
    player.setTitleList(DAOManager.getDAO(PlayerTitleListDAO.class).loadTitleList(playerObjId));
    DAOManager.getDAO(PlayerSettingsDAO.class).loadSettings(player);
    DAOManager.getDAO(AbyssRankDAO.class).loadAbyssRank(player);
    DAOManager.getDAO(PlayerNpcFactionsDAO.class).loadNpcFactions(player);
    DAOManager.getDAO(MotionDAO.class).loadMotionList(player);
    player.setVars(DAOManager.getDAO(PlayerVarsDAO.class).load(player.getObjectId()));
    Equipment equipment = DAOManager.getDAO(InventoryDAO.class).loadEquipment(player);
    ItemService.loadItemStones(equipment.getEquippedItemsWithoutStigma());
    equipment.setOwner(player);
    player.setEquipment(equipment);
    player.setEffectController(new PlayerEffectController(player));
    player.setFlyController(new FlyController(player));
    PlayerStatFunctions.addPredefinedStatFunctions(player);

    player.setQuestStateList(DAOManager.getDAO(PlayerQuestListDAO.class).load(player));
    player.setRecipeList(DAOManager.getDAO(PlayerRecipesDAO.class).load(player.getObjectId()));

    /** Account warehouse should be already loaded in account */
    Storage accWarehouse = account.getAccountWarehouse();
    player.setStorage(accWarehouse, StorageType.ACCOUNT_WAREHOUSE);

    Storage inventory =
        DAOManager.getDAO(InventoryDAO.class).loadStorage(playerObjId, StorageType.CUBE);
    ItemService.loadItemStones(inventory.getItems());

    player.setStorage(inventory, StorageType.CUBE);

    for (int petBagId = 32; petBagId < 36; petBagId++) {
      Storage petBag =
          DAOManager.getDAO(InventoryDAO.class)
              .loadStorage(playerObjId, StorageType.getStorageTypeById(petBagId));
      ItemService.loadItemStones(petBag.getItems());

      player.setStorage(petBag, StorageType.getStorageTypeById(petBagId));
    }

    Storage warehouse =
        DAOManager.getDAO(InventoryDAO.class)
            .loadStorage(playerObjId, StorageType.REGULAR_WAREHOUSE);
    ItemService.loadItemStones(warehouse.getItems());

    player.setStorage(warehouse, StorageType.REGULAR_WAREHOUSE);

    /** Apply equipment stats (items and manastones were loaded in account) */
    player.getEquipment().onLoadApplyEquipmentStats();

    DAOManager.getDAO(PlayerPunishmentsDAO.class)
        .loadPlayerPunishments(player, PunishmentType.PRISON);
    DAOManager.getDAO(PlayerPunishmentsDAO.class)
        .loadPlayerPunishments(player, PunishmentType.GATHER);

    // update passive stats after effect controller, stats and equipment are initialized
    player.getController().updatePassiveStats();
    // load saved effects
    DAOManager.getDAO(PlayerEffectsDAO.class).loadPlayerEffects(player);
    // load saved player cooldowns
    DAOManager.getDAO(PlayerCooldownsDAO.class).loadPlayerCooldowns(player);
    // load item cooldowns
    DAOManager.getDAO(ItemCooldownsDAO.class).loadItemCooldowns(player);
    // load portal cooldowns
    DAOManager.getDAO(PortalCooldownsDAO.class).loadPortalCooldowns(player);
    // load bind point
    DAOManager.getDAO(PlayerBindPointDAO.class).loadBindPoint(player);
    // load craft cooldowns
    DAOManager.getDAO(CraftCooldownsDAO.class).loadCraftCooldowns(player);

    if (player.getCommonData().getTitleId() > 0) {
      TitleChangeListener.onTitleChange(
          player.getGameStats(), player.getCommonData().getTitleId(), true);
    }

    DAOManager.getDAO(PlayerLifeStatsDAO.class).loadPlayerLifeStat(player);
    DAOManager.getDAO(PlayerEmotionListDAO.class).loadEmotions(player);

    // analyze current instance
    InstanceService.onPlayerLogin(player);

    if (CacheConfig.CACHE_PLAYERS) playerCache.put(playerObjId, player);

    return player;
  }