Exemplo n.º 1
0
  /**
   * Cancel Player deletion process if its possible.
   *
   * @param accData PlayerAccountData
   * @return True if deletion was successful canceled.
   */
  public static boolean cancelPlayerDeletion(PlayerAccountData accData) {
    if (accData.getDeletionDate() == null) return true;

    if (accData.getDeletionDate().getTime() > System.currentTimeMillis()) {
      accData.setDeletionDate(null);
      storeDeletionTime(accData);
      return true;
    }
    return false;
  }
Exemplo n.º 2
0
 /**
  * Updates deletion time in database
  *
  * @param accData PlayerAccountData
  */
 private static void storeDeletionTime(PlayerAccountData accData) {
   DAOManager.getDAO(PlayerDAO.class)
       .updateDeletionTime(
           accData.getPlayerCommonData().getPlayerObjId(), accData.getDeletionDate());
 }
Exemplo n.º 3
0
  /**
   * Starts player deletion process if its possible. If deletion is possible character should be
   * deleted after 5 minutes.
   *
   * @param accData PlayerAccountData
   */
  public static void deletePlayer(PlayerAccountData accData) {
    if (accData.getDeletionDate() != null) return;

    accData.setDeletionDate(new Timestamp(System.currentTimeMillis() + 5 * 60 * 1000));
    storeDeletionTime(accData);
  }
Exemplo n.º 4
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);

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

    if (GroupService.getInstance().isGroupMember(playerObjId))
      GroupService.getInstance().setGroup(player);

    if (AllianceService.getInstance().isAllianceMember(playerObjId))
      AllianceService.getInstance().setAlliance(player);

    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);
    PlayerStatsData playerStatsData = DataManager.PLAYER_STATS_DATA;
    player.setPlayerStatsTemplate(playerStatsData.getTemplate(player));

    player.setGameStats(new PlayerGameStats(playerStatsData, player));

    Equipment equipment = DAOManager.getDAO(InventoryDAO.class).loadEquipment(player);
    ItemService.loadItemStones(equipment.getEquippedItemsWithoutStigma());
    equipment.setOwner(player);
    player.setEquipment(equipment);

    player.setLifeStats(new PlayerLifeStats(player));
    player.setEffectController(new PlayerEffectController(player));
    player.setFlyController(new FlyController(player));
    player.setReviveController(new ReviveController(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(player, player.getObjectId(), StorageType.CUBE);
    ItemService.loadItemStones(inventory.getStorageItems());

    player.setStorage(inventory, StorageType.CUBE);

    Storage warehouse =
        DAOManager.getDAO(InventoryDAO.class)
            .loadStorage(player, player.getObjectId(), StorageType.REGULAR_WAREHOUSE);
    ItemService.loadItemStones(warehouse.getStorageItems());

    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);

    ItemService.restoreKinah(player);

    // update passive stats after effect controller, stats and equipment are initialized
    player.getController().updatePassiveStats();
    // load saved effects
    DAOManager.getDAO(PlayerEffectsDAO.class).loadPlayerEffects(player);
    // load item cooldowns
    DAOManager.getDAO(ItemCooldownsDAO.class).loadItemCooldowns(player);

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

    DAOManager.getDAO(PlayerLifeStatsDAO.class).loadPlayerLifeStat(player);
    // analyze current instance
    InstanceService.onPlayerLogin(player);

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

    return player;
  }