Java Code Examples for javolution.util.FastMap#get()

The following examples show how to use javolution.util.FastMap#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NpcShoutData.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get global npc shouts plus world specific shouts. Make sure to clean it after the use.
 *
 * @return null if not found
 */
public List<NpcShout> getNpcShouts(int worldId, int npcId) {
	FastMap<Integer, List<NpcShout>> worldShouts = shoutsByWorldNpcs.get(0);

	if (worldShouts == null || worldShouts.get(npcId) == null) {
		worldShouts = shoutsByWorldNpcs.get(worldId);
		if (worldShouts == null || worldShouts.get(npcId) == null) {
			return null;
		}
		return new ArrayList<NpcShout>(worldShouts.get(npcId));
	}

	List<NpcShout> npcShouts = new ArrayList<NpcShout>(worldShouts.get(npcId));
	worldShouts = shoutsByWorldNpcs.get(worldId);
	if (worldShouts == null || worldShouts.get(npcId) == null) {
		return npcShouts;
	}
	npcShouts.addAll(worldShouts.get(npcId));

	return npcShouts;
}
 
Example 2
Source File: ItemUpgradeService.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public static boolean decreaseMaterial(Player player, Item baseItem, int resultItemId) {
	FastMap<Integer, UpgradeResultItem> resultItemMap = DataManager.ITEM_UPGRADE_DATA.getResultItemMap(baseItem.getItemId());

	UpgradeResultItem resultItem = resultItemMap.get(resultItemId);
	if (resultItem.getNeed_kinah() == null) {
		for (SubMaterialItem item : resultItem.getUpgrade_materials().getSubMaterialItem()) {
			if (!player.getInventory().decreaseByItemId(item.getId(), item.getCount())) {
				AuditLogger.info(player, "try item upgrade without sub material");
				return false;
			}
		}
	} 
	else {
		player.getInventory().decreaseKinah(-resultItem.getNeed_kinah().getCount());
	}
	if (resultItem.getNeed_abyss_point() != null) {
		AbyssPointsService.setAp(player, -resultItem.getNeed_abyss_point().getCount());
	}
	if (resultItem.getNeed_kinah() != null) {
		player.getInventory().decreaseKinah(-resultItem.getNeed_kinah().getCount());
	}
	player.getInventory().decreaseByObjectId(baseItem.getObjectId(), 1);
	return true;
}
 
Example 3
Source File: NpcShoutData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void afterUnmarshal(Unmarshaller u, Object parent) {
	for (ShoutGroup group : shoutGroups) {
		for (int i = group.getShoutNpcs().size() - 1; i >= 0; i--) {
			ShoutList shoutList = group.getShoutNpcs().get(i);
			int worldId = shoutList.getRestrictWorld();

			FastMap<Integer, List<NpcShout>> worldShouts = shoutsByWorldNpcs.get(worldId);
			if (worldShouts == null) {
				worldShouts = FastMap.newInstance();
				this.shoutsByWorldNpcs.put(worldId, worldShouts);
			}

			this.count += shoutList.getNpcShouts().size();
			for (int j = shoutList.getNpcIds().size() - 1; j >= 0; j--) {
				int npcId = shoutList.getNpcIds().get(j);
				List<NpcShout> shouts = new ArrayList<NpcShout>(shoutList.getNpcShouts());
				if (worldShouts.get(npcId) == null) {
					worldShouts.put(npcId, shouts);
				}
				else {
					worldShouts.get(npcId).addAll(shouts);
				}
				shoutList.getNpcIds().remove(j);
			}
			shoutList.getNpcShouts().clear();
			shoutList.makeNull();
			group.getShoutNpcs().remove(i);
		}
		group.makeNull();
	}
	this.shoutGroups.clear();
	this.shoutGroups = null;
}
 
Example 4
Source File: NpcShoutData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Lightweight check for shouts, doesn't use memory as {@link #getNpcShouts(int worldId, int npcId)})
 */
public boolean hasAnyShout(int worldId, int npcId) {
	FastMap<Integer, List<NpcShout>> worldShouts = shoutsByWorldNpcs.get(0);

	if (worldShouts == null || worldShouts.get(npcId) == null) {
		worldShouts = shoutsByWorldNpcs.get(worldId);
		if (worldShouts == null || worldShouts.get(npcId) == null) {
			return false;
		}
	}
	return true;
}
 
Example 5
Source File: ItemGroupsData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
void MapCraftReward(FastMap<Integer, FastMap<IntRange, List<CraftReward>>> dataHolder, CraftReward reward) {
	FastMap<IntRange, List<CraftReward>> ranges;
	int lowerBound = 0, upperBound = 0;

	if (reward instanceof CraftRecipe) {
		CraftRecipe recipe = (CraftRecipe) reward;
		lowerBound = recipe.getLevel();
		upperBound = lowerBound + RECIPE_UPPER;
		if (upperBound / 100 != lowerBound / 100) {
			upperBound = lowerBound / 100 + 99;
		}
	}
	else {
		CraftItem item = (CraftItem) reward;
		lowerBound = item.getMinLevel();
		upperBound = item.getMaxLevel();
	}

	IntRange range = new IntRange(lowerBound, upperBound);

	if (dataHolder.containsKey(reward.getSkill())) {
		ranges = dataHolder.get(reward.getSkill());
	}
	else {
		ranges = new FastMap<IntRange, List<CraftReward>>();
		dataHolder.put(reward.getSkill(), ranges);
	}

	List<CraftReward> items;
	if (ranges.containsKey(range)) {
		items = ranges.get(range);
	}
	else {
		items = new ArrayList<CraftReward>();
		ranges.put(range, items);
	}
	items.add(reward);
}
 
Example 6
Source File: ItemUpgradeService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public static boolean checkItemUpgrade(Player player, Item baseItem, int resultItemId) {
	ItemUpgradeTemplate itemUpgradeTemplate = DataManager.ITEM_UPGRADE_DATA.getItemUpgradeTemplate(baseItem.getItemId());
	if (itemUpgradeTemplate == null) {
		log.warn(resultItemId + " item's itemupgrade template is null");
		return false;
	}
	FastMap<Integer, UpgradeResultItem> resultItemMap = DataManager.ITEM_UPGRADE_DATA.getResultItemMap(baseItem.getItemId());
	if (!resultItemMap.containsKey(resultItemId)) {
		AuditLogger.info(player, resultItemId + " item's baseItem and resultItem is not matched (possible client modify)");
		return false;
	}
	UpgradeResultItem resultItem = resultItemMap.get(resultItemId);
	if (resultItem.getCheck_enchant_count() > 0) {
		if (baseItem.getEnchantOrAuthorizeLevel() < resultItem.getCheck_enchant_count()) {
			PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_REGISTER_ITEM_MSG_UPGRADE_CANNOT(new DescriptionId(baseItem.getNameId())));
			return false;
		}
	}
	if (resultItem.getNeed_abyss_point() != null) {
		if (player.getAbyssRank().getAp() < resultItem.getNeed_abyss_point().getCount()) {
			PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_REGISTER_ITEM_MSG_UPGRADE_CANNOT_NEED_AP);
			return false;
		}
	}
	if (resultItem.getNeed_kinah() == null) {
		for (SubMaterialItem sub : resultItem.getUpgrade_materials().getSubMaterialItem()) {
			if (player.getInventory().getItemCountByItemId(sub.getId()) < sub.getCount()) {
				// SubMaterial is not enough
				return false;
			}
		}
	} 
	else {
		if (player.getInventory().getKinah() < resultItem.getNeed_kinah().getCount()) {
			PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_REGISTER_ITEM_MSG_UPGRADE_CANNOT_NEED_QINA);
			return false;
		}
	}
	return true;
}