테스트

aion-server 4.8

Gitteol
최고관리자 · 1 · 💬 0 클론/새로받기
 4.8 61f661d · 1 commits 새로받기(Pull)
game-server/src/com/aionemu/gameserver/services/AccountService.java
package com.aionemu.gameserver.services;

import java.util.Iterator;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aionemu.gameserver.GameServer;
import com.aionemu.gameserver.configs.main.GSConfig;
import com.aionemu.gameserver.dao.*;
import com.aionemu.gameserver.model.Race;
import com.aionemu.gameserver.model.account.Account;
import com.aionemu.gameserver.model.account.AccountTime;
import com.aionemu.gameserver.model.account.CharacterBanInfo;
import com.aionemu.gameserver.model.account.PlayerAccountData;
import com.aionemu.gameserver.model.gameobjects.player.PlayerAppearance;
import com.aionemu.gameserver.model.gameobjects.player.PlayerCommonData;
import com.aionemu.gameserver.model.items.storage.PlayerStorage;
import com.aionemu.gameserver.model.items.storage.Storage;
import com.aionemu.gameserver.model.items.storage.StorageType;
import com.aionemu.gameserver.model.team.legion.LegionMember;
import com.aionemu.gameserver.services.player.PlayerService;

/**
 * This class is a front-end for daos and it's responsibility is to retrieve the Account objects
 * 
 * @author Luno, cura
 */
public class AccountService {

	private static final Logger log = LoggerFactory.getLogger(AccountService.class);

	/**
	 * Returns {@link Account} object that has given id.
	 */
	public static Account getAccount(int accountId, String accountName, long creationDate, AccountTime accountTime, byte accessLevel, byte membership,
		long toll, String allowedHddSerial) {
		log.debug("[AS] request for account: " + accountId);

		Account account = loadAccount(accountId);
		account.setName(accountName);
		account.setCreationDate(creationDate);
		account.setAccountTime(accountTime);
		account.setAccessLevel(accessLevel);
		account.setMembership(membership);
		account.setToll(toll);
		account.setAllowedHddSerial(allowedHddSerial);
		removeDeletedCharacters(account);
		return account;
	}

	/**
	 * Removes from db characters that should be deleted (their deletion time has passed).
	 */
	public static void removeDeletedCharacters(Account account) {
		/* Removes chars that should be removed */
		for (Iterator<PlayerAccountData> it = account.iterator(); it.hasNext(); ) {
			PlayerAccountData pad = it.next();
			Race race = pad.getPlayerCommonData().getRace();
			long deletionTime = pad.getDeletionDate() == null ? 0 : pad.getDeletionDate().getTime();
			if (deletionTime != 0 && deletionTime <= System.currentTimeMillis()) {
				it.remove();
				account.decrementCountOf(race);
				PlayerService.deletePlayerFromDB(pad.getPlayerCommonData().getPlayerObjId());
				if (GSConfig.ENABLE_RATIO_LIMITATION && pad.getPlayerCommonData().getLevel() >= GSConfig.RATIO_MIN_REQUIRED_LEVEL) {
					if (account.getNumberOf(race) == 0) {
						GameServer.updateRatio(pad.getPlayerCommonData().getRace(), -1);
					}
				}
				if (account.isEmpty()) {
					InventoryDAO.deleteAccountWH(account.getId());
					account.setAccountWarehouse(loadAccountWarehouse(account));
					break;
				}
			}
		}
	}

	public static Account loadAccount(int accountId) {
		Account account = new Account(accountId);
		List<Integer> playerIdList = PlayerDAO.getPlayerOidsOnAccount(accountId);
		for (int playerId : playerIdList)
			account.addPlayerAccountData(loadPlayerAccountData(playerId));
		account.setAccountWarehouse(loadAccountWarehouse(account));
		return account;
	}

	public static PlayerAccountData loadPlayerAccountData(int playerId) {
		PlayerCommonData playerCommonData = PlayerDAO.loadPlayerCommonData(playerId);
		CharacterBanInfo cbi = PlayerPunishmentsDAO.getCharBanInfo(playerId);
		PlayerAppearance appereance = PlayerAppearanceDAO.load(playerId);
		LegionMember legionMember = LegionMemberDAO.loadLegionMember(playerId);
		// Load only equipment and its stones to display on character selection screen
		List<PlayerAccountData.VisibleItem> equipment = InventoryDAO.loadVisibleEquipment(playerId);
		PlayerAccountData playerAccData = new PlayerAccountData(playerCommonData, appereance, cbi, equipment, legionMember);
		PlayerDAO.setCreationDeletionTime(playerAccData);
		return playerAccData;
	}

	public static Storage loadAccountWarehouse(Account account) {
		Storage wh = new PlayerStorage(null, StorageType.ACCOUNT_WAREHOUSE);
		InventoryDAO.loadStorage(account.getId(), wh);
		ItemStoneListDAO.load(wh.getItems());
		return wh;
	}
}

📎 첨부파일

댓글 작성 권한이 없습니다.
🏆 포인트 랭킹 TOP 10
순위 닉네임 포인트
1 no_profile 타키야겐지쪽지보내기 자기소개 아이디로 검색 전체게시물 102,949
2 no_profile 동가리쪽지보내기 자기소개 아이디로 검색 전체게시물 63,733
3 no_profile 라프텔쪽지보내기 자기소개 아이디로 검색 전체게시물 51,771
4 no_profile 불멸의행복쪽지보내기 자기소개 아이디로 검색 전체게시물 36,923
5 서번트쪽지보내기 자기소개 아이디로 검색 전체게시물 35,011
6 no_profile 닥터스쪽지보내기 자기소개 아이디로 검색 전체게시물 29,470
7 no_profile 검은고양이쪽지보내기 자기소개 아이디로 검색 전체게시물 29,077
8 no_profile Revolution쪽지보내기 자기소개 아이디로 검색 전체게시물 28,199
9 no_profile 보거스쪽지보내기 자기소개 아이디로 검색 전체게시물 26,731
10 no_profile 호롤롤로쪽지보내기 자기소개 아이디로 검색 전체게시물 17,020
알림 0