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

The following examples show how to use javolution.util.FastMap#put() . 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: SiegeService.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public void onEnterSiegeWorld(Player player) {
	// Second part only for siege world
	FastMap<Integer, SiegeLocation> worldLocations = new FastMap<Integer, SiegeLocation>();
	FastMap<Integer, ArtifactLocation> worldArtifacts = new FastMap<Integer, ArtifactLocation>();

	for (SiegeLocation location : getSiegeLocations().values()) {
		if (location.getWorldId() == player.getWorldId()) {
			worldLocations.put(location.getLocationId(), location);
		}
	}

	for (ArtifactLocation artifact : getArtifacts().values()) {
		if (artifact.getWorldId() == player.getWorldId()) {
			worldArtifacts.put(artifact.getLocationId(), artifact);
		}
	}

	PacketSendUtility.sendPacket(player, new SM_SHIELD_EFFECT(worldLocations.values()));
	PacketSendUtility.sendPacket(player, new SM_ABYSS_ARTIFACT_INFO(worldArtifacts.values()));
}
 
Example 2
Source File: MySQL5CraftCooldownsDAO.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void loadCraftCooldowns(final Player player) {
	Connection con = null;
	FastMap<Integer, Long> craftCoolDowns = new FastMap<Integer, Long>();
	try {
		con = DatabaseFactory.getConnection();
		PreparedStatement stmt = con.prepareStatement(SELECT_QUERY);

		stmt.setInt(1, player.getObjectId());
		ResultSet rset = stmt.executeQuery();

		while (rset.next()) {
			int delayId = rset.getInt("delay_id");
			long reuseTime = rset.getLong("reuse_time");
			int delay = (int) ((reuseTime - System.currentTimeMillis()) / 1000);

			if (delay > 0) {
				craftCoolDowns.put(delayId, reuseTime);
			}
		}
		player.getCraftCooldownList().setCraftCoolDowns(craftCoolDowns);
		rset.close();
		stmt.close();
	}
	catch (SQLException e) {
		log.error("LoadcraftCoolDowns", e);
	}
	finally {
		DatabaseFactory.close(con);
	}
}
 
Example 3
Source File: MySQL5PortalCooldownsDAO.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void loadPortalCooldowns(final Player player) {
	Connection con = null;
	FastMap<Integer, PortalCooldownItem> portalCoolDowns = new FastMap<Integer, PortalCooldownItem>();
	PreparedStatement stmt = null;
	try {
		con = DatabaseFactory.getConnection();
		stmt = con.prepareStatement(SELECT_QUERY);

		stmt.setInt(1, player.getObjectId());
		ResultSet rset = stmt.executeQuery();

		while (rset.next()) {
			int worldId = rset.getInt("world_id");
			long reuseTime = rset.getLong("reuse_time");
			int entryCount = rset.getInt("entry_count");
			if (reuseTime > System.currentTimeMillis()) {
				portalCoolDowns.put(worldId, new PortalCooldownItem(worldId, entryCount, reuseTime));
			}
		}
		player.getPortalCooldownList().setPortalCoolDowns(portalCoolDowns);
		rset.close();
	}
	catch (SQLException e) {
		log.error("LoadPortalCooldowns", e);
	}
	finally {
		DatabaseFactory.close(stmt, con);
	}
}
 
Example 4
Source File: MySQL5ChallengeTasksDAO.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Map<Integer, ChallengeTask> load(int ownerId, ChallengeType type) {
	FastMap<Integer, ChallengeTask> tasks = new FastMap<Integer, ChallengeTask>().shared();
	Connection conn = null;
	try {
		conn = DatabaseFactory.getConnection();
		PreparedStatement stmt = conn.prepareStatement(SELECT_QUERY);
		stmt.setInt(1, ownerId);
		stmt.setString(2, type.toString());
		ResultSet rset = stmt.executeQuery();
		while (rset.next()) {
			int taskId = rset.getInt("task_id");
			int questId = rset.getInt("quest_id");
			int completeCount = rset.getInt("complete_count");
			Timestamp date = rset.getTimestamp("complete_time");
			ChallengeQuestTemplate template = DataManager.CHALLENGE_DATA.getQuestByQuestId(questId);
			ChallengeQuest quest = new ChallengeQuest(template, completeCount);
			quest.setPersistentState(PersistentState.UPDATED);
			if (!tasks.containsKey(taskId)) {
				Map<Integer, ChallengeQuest> quests = new HashMap<Integer, ChallengeQuest>(2);
				quests.put(quest.getQuestId(), quest);
				ChallengeTask task = new ChallengeTask(taskId, ownerId, quests, date);
				tasks.put(taskId, task);
			}
			else {
				tasks.get(taskId).getQuests().put(questId, quest);
			}
		}
		rset.close();
		stmt.close();
	}
	catch (SQLException e) {
		log.error("Error while loading challenge task. " + e);
	}
	finally {
		DatabaseFactory.close(conn);
	}
	return tasks;
}
 
Example 5
Source File: MySQL5HouseObjectCooldownsDAO.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void loadHouseObjectCooldowns(final Player player) {
	Connection con = null;
	FastMap<Integer, Long> houseObjectCoolDowns = new FastMap<Integer, Long>();
	try {
		con = DatabaseFactory.getConnection();
		PreparedStatement stmt = con.prepareStatement(SELECT_QUERY);

		stmt.setInt(1, player.getObjectId());
		ResultSet rset = stmt.executeQuery();

		while (rset.next()) {
			int objectId = rset.getInt("object_id");
			long reuseTime = rset.getLong("reuse_time");
			int delay = (int) ((reuseTime - System.currentTimeMillis()) / 1000);

			if (delay > 0) {
				houseObjectCoolDowns.put(objectId, reuseTime);
			}
		}
		player.getHouseObjectCooldownList().setHouseObjectCooldowns(houseObjectCoolDowns);
		rset.close();
		stmt.close();
	}
	catch (SQLException e) {
		log.error("LoadHouseObjectCooldowns", e);
	}
	finally {
		DatabaseFactory.close(con);
	}
}
 
Example 6
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 7
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 8
Source File: ReportToManyData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void register(QuestEngine questEngine) {
	int maxVar = 0;
	FastMap<Integer, NpcInfos> NpcInfo = new FastMap<Integer, NpcInfos>();
	for (NpcInfos mi : npcInfos) {
		NpcInfo.put(mi.getNpcId(), mi);
		if (mi.getVar() > maxVar) {
			maxVar = mi.getVar();
		}
	}
	ReportToMany template = new ReportToMany(id, startItemId, startNpcIds, endNpcIds, NpcInfo, startDialog, endDialog, maxVar, mission);
	questEngine.addQuestHandler(template);
}
 
Example 9
Source File: KillSpawnedData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void register(QuestEngine questEngine) {
	FastMap<List<Integer>, SpawnedMonster> spawnedMonsters = new FastMap<List<Integer>, SpawnedMonster>();
	for (SpawnedMonster m : spawnedMonster) {
		spawnedMonsters.put(m.getNpcIds(), m);
	}
	KillSpawned template = new KillSpawned(id, startNpcIds, endNpcIds, spawnedMonsters);
	questEngine.addQuestHandler(template);
}
 
Example 10
Source File: SkillUseData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void register(QuestEngine questEngine) {
	FastMap<List<Integer>, QuestSkillData> questSkills = new FastMap<List<Integer>, QuestSkillData>();
	for (QuestSkillData qsd : skills) {
		questSkills.put(qsd.getSkillIds(), qsd);
	}
	SkillUse questTemplate = new SkillUse(id, startNpc, endNpc, questSkills);
	questEngine.addQuestHandler(questTemplate);
}
 
Example 11
Source File: MinionService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void adoptMinion(Player player, Item item, String grade) {
	FastMap<Integer, MinionTemplate> minionTemplate =  new FastMap<Integer, MinionTemplate>();
	int minionId = 0;
	int minionLvl = 0;
	int minionGrowthPoints = 0;
	String minionName = "";
	String minionGrade = "";
	for (MinionTemplate template : DataManager.MINION_DATA.getMinionData().valueCollection()) {
		if (template.getGrade().equalsIgnoreCase(grade) && template.getLevel() == 1) {
			minionTemplate.put(template.getId(), template);
		}
	}
	int rnd = Rnd.get((int) 1, (int) minionTemplate.size());
	int i = 1;
	for (MinionTemplate mt : minionTemplate.values()) {
		if (i == rnd) {
			minionId = mt.getId();
			minionName = mt.getName();
			minionGrade = mt.getGrade();
			minionLvl = mt.getLevel();
			minionGrowthPoints = mt.getGrowthPt();
			break;
		}
		++i;
	}
	if (!validateAdoption(player, item.getItemTemplate(), minionId)) {
		return;
	}
	addMinion(player, minionId, minionName, minionGrade, minionLvl, minionGrowthPoints);
	player.getMinionList().updateMinionsList();
}
 
Example 12
Source File: TransformationService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void adoptTransformation(Player player, Item item, String grade) {
	FastMap<Integer, TransformationTemplate> transformationTemplate =  new FastMap<Integer, TransformationTemplate>();
	int transformationId = 0;
	String transformationName = "";
	String transformationGrade = "";
	for (TransformationTemplate template : DataManager.TRANSFORMATION_DATA.getTransformationData().valueCollection()) {
		if (template.getGrade().equalsIgnoreCase(grade)) {
			transformationTemplate.put(template.getId(), template);
		}
	}
	int rnd = Rnd.get((int) 1, (int) transformationTemplate.size());
	int i = 1;
	for (TransformationTemplate tt : transformationTemplate.values()) {
		if (i == rnd) {
			transformationId = tt.getId();
			transformationName = tt.getName();
			transformationGrade = tt.getGrade();
			break;
		}
		++i;
	}
	if (!validateAdoption(player, item.getItemTemplate(), transformationId)) {
		return;
	}
	addTransformation(player, transformationId, transformationName, transformationGrade);
	player.getTransformationList().updateTransformationsList();
}
 
Example 13
Source File: RiftInformer.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private static FastMap<Integer, Integer> getAnnounceData(int worldId) {
	FastMap<Integer, Integer> localRifts = new FastMap<Integer, Integer>();

	// init empty list
	for (int i = 0; i < 14; i++) { //OLD 8 (TODO)
		localRifts.put(i, 0);
	}

	for (Npc rift : getSpawned(worldId)) {
		RVController rc = (RVController) rift.getController();
		localRifts = calcRiftsData(rc, localRifts);
	}

	return localRifts;
}
 
Example 14
Source File: DElement.java    From org.openntf.domino with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Object> toMap(final String[] props) {
	FastMap<String, Object> result = new FastMap<String, Object>();
	for (String prop : props) {
		result.put(prop, getProperty(prop));
	}
	return result.unmodifiable();
}
 
Example 15
Source File: MonsterHuntData.java    From aion-germany with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void register(QuestEngine questEngine) {
	FastMap<Monster, Set<Integer>> monsterNpcs = new FastMap<Monster, Set<Integer>>();
	QuestTemplate questTemplate = DataManager.QUEST_DATA.getQuestById(id);
	for (Monster m : monster) {
		if (CustomConfig.QUESTDATA_MONSTER_KILLS) {
			// if sequence numbers specified use it
			if (m.getNpcSequence() != null && questTemplate.getQuestKill() != null) {
				QuestKill killNpcs = null;
				for (int index = 0; index < questTemplate.getQuestKill().size(); index++) {
					if (questTemplate.getQuestKill().get(index).getSequenceNumber() == m.getNpcSequence()) {
						killNpcs = questTemplate.getQuestKill().get(index);
						break;
					}
				}
				if (killNpcs != null) {
					monsterNpcs.put(m, killNpcs.getNpcIds());
				}
			} // if no sequence was specified, check all npc ids to match quest data
				// else if (m.getNpcSequence() == null && questTemplate.getQuestKill() != null) {
				// Set<Integer> npcSet = new HashSet<Integer>(m.getNpcIds());
				// QuestKill matchedKillNpcs = null;
				// int maxMatchCount = 0;
				// for (int index = 0; index < questTemplate.getQuestKill().size(); index++) {
				// QuestKill killNpcs = questTemplate.getQuestKill().get(index);
				// int matchCount = 0;
				// for (int npcId : killNpcs.getNpcIds()) {
				// if (!npcSet.contains(npcId)) {
				// continue;
				// }
				// matchCount++;
				// }
				// if (matchCount > maxMatchCount) {
				// maxMatchCount = matchCount;
				// matchedKillNpcs = killNpcs;
				// }
				// }
				// if (matchedKillNpcs != null) {
				// // add npcs not present in quest data (weird!)
				// npcSet.addAll(matchedKillNpcs.getNpcIds());
				// monsterNpcs.put(m, npcSet);
				// }
				// }
			else {
				monsterNpcs.put(m, new HashSet<Integer>(m.getNpcIds()));
			}
		}
		else {
			monsterNpcs.put(m, new HashSet<Integer>(m.getNpcIds()));
		}
	}
	MonsterHunt template = new MonsterHunt(id, startNpcIds, endNpcIds, monsterNpcs, startDialog, endDialog, aggroNpcs, invasionWorld);
	questEngine.addQuestHandler(template);
}