javolution.util.FastList Java Examples

The following examples show how to use javolution.util.FastList. 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: PacketFormat.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public static List<PartType> getIdPartsInString(String str)
{
	FastList<PartType> list = new FastList<PartType>();
	str = str.trim();
	int i = 0;
	if(str.charAt(i) == '(')
	{
		i++;
		while(str.charAt(i) != ')')
		{
			if(str.charAt(i) != ' ')
			{
                   PartType type = PartTypeManager.getInstance().getType(str.substring(i, i+1));
				if(type == null)
				{
					return null;
				}
                   list.add(type);
			}
			i++;
		}
	}
	return list;
}
 
Example #2
Source File: SpawnsTool.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public static void load()
{
	maps = new WorldMaps();
	mapNameById = new FastMap<Integer, String>();
	npc = new FastList<SpawnTemplates>();
	base = new FastList<SpawnTemplates>();
	siege = new FastList<SpawnTemplates>();
	conquest = new FastList<SpawnTemplates>();
	gather = new FastList<SpawnTemplates>();
	ids_conquest = new FastList<Integer>();
	ids_base = new FastList<Integer>();
	ids_siege = new FastList<Integer>();
	ids_npc = new FastList<Integer>();
	ids_gather = new FastList<Integer>();
	gatherSpawnsByWorldId = new FastMap<Integer, FastMap<Integer, SpawnTemplate>>();
	conquestSpawnsByWorldId = new FastMap<Integer, FastMap<Integer, SpawnTemplate>>();
	
	
	load("WorldMap");
	load("Npcs");
	load("Gather");
	load("Sieges");
	load("Bases");
	load("Conquest");
}
 
Example #3
Source File: BalaurAssaultService.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public void spawnDredgion(int spawnId) {
	AssembledNpcTemplate template = DataManager.ASSEMBLED_NPC_DATA.getAssembledNpcTemplate(spawnId);
	FastList<AssembledNpcPart> assembledParts = new FastList<AssembledNpcPart>();
	for (AssembledNpcTemplate.AssembledNpcPartTemplate npcPart : template.getAssembledNpcPartTemplates()) {
		assembledParts.add(new AssembledNpcPart(IDFactory.getInstance().nextId(), npcPart));
	}

	AssembledNpc npc = new AssembledNpc(template.getRouteId(), template.getMapId(), template.getLiveTime(), assembledParts);
	Iterator<Player> iter = World.getInstance().getPlayersIterator();
	Player findedPlayer;
	while (iter.hasNext()) {
		findedPlayer = iter.next();
		PacketSendUtility.sendPacket(findedPlayer, new SM_NPC_ASSEMBLER(npc));
		// A dredgion has appeared
		PacketSendUtility.sendPacket(findedPlayer, SM_SYSTEM_MESSAGE.STR_ABYSS_CARRIER_SPAWN);
	}
}
 
Example #4
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
public void store() {
		try {
			XMLObjectWriter writer = XMLObjectWriter.newInstance(new FileOutputStream(persistFile.toString()));
			writer.setBinding(binding);
			// Enables cross-references.
			// writer.setReferenceResolver(new XMLReferenceResolver());
			writer.setIndentation(TAB_INDENT);

            writer.write(this.connectDelay, CONNECT_DELAY_PROP, Integer.class);
//            writer.write(this.workerThreads, WORKER_THREADS_PROP, Integer.class);
//            writer.write(this.singleThread, SINGLE_THREAD_PROP, Boolean.class);

			writer.write(this.servers, SERVERS, FastList.class);
			writer.write(this.associations, ASSOCIATIONS, AssociationMap.class);

			writer.close();
		} catch (Exception e) {
			logger.error("Error while persisting the Rule state in file", e);
		}
	}
 
Example #5
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
public void stopServer(String serverName) throws Exception {

		if (!this.started) {
			throw new Exception(String.format("Management=%s not started", this.name));
		}

		if (serverName == null) {
			throw new Exception("Server name cannot be null");
		}

		FastList<Server> tempServers = servers;
		for (FastList.Node<Server> n = tempServers.head(), end = tempServers.tail(); (n = n.getNext()) != end;) {
			Server serverTemp = n.getValue();

			if (serverName.equals(serverTemp.getName())) {
				((ServerImpl) serverTemp).stop();
				this.store();
				return;
			}
		}

		throw new Exception(String.format("No Server found with name=%s", serverName));
	}
 
Example #6
Source File: ManagementImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
public void startServer(String serverName) throws Exception {

		if (!this.started) {
			throw new Exception(String.format("Management=%s not started", this.name));
		}

		if (name == null) {
			throw new Exception("Server name cannot be null");
		}

		FastList<Server> tempServers = servers;
		for (FastList.Node<Server> n = tempServers.head(), end = tempServers.tail(); (n = n.getNext()) != end;) {
			Server serverTemp = n.getValue();

			if (serverName.equals(serverTemp.getName())) {
				if (serverTemp.isStarted()) {
					throw new Exception(String.format("Server=%s is already started", serverName));
				}
				((ServerImpl) serverTemp).start();
				this.store();
				return;
			}
		}

		throw new Exception(String.format("No Server foubd with name=%s", serverName));
	}
 
Example #7
Source File: LunaShopService.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public void generateDailyCraft() {
	if (DailyCraft.size() > 0) {
		dailyGenerated = false;
		DailyCraft.clear();
	}
	
	FastList<LunaTemplate> test = DataManager.LUNA_DATA.getLunaTemplatesAny();
	Random rand = new Random();
	for (int i = 0; i < 5; i++) {
        int randomIndex = rand.nextInt(test.size());
        LunaTemplate randomElement = test.get(randomIndex);
        DailyCraft.add(randomElement.getId());
	}

	if (!dailyGenerated) {
		updateDailyCraft();
	}
}
 
Example #8
Source File: Equipment.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return List<Item>
 */
public FastList<Item> getEquippedItemsWithoutStigma() {
	FastList<Item> equippedItems = FastList.newInstance();
	Item twoHanded = null;
	for (Item item : equipment.values()) {
		if (!ItemSlot.isStigma(item.getEquipmentSlot())) {
			if (item.getItemTemplate().isTwoHandWeapon()) {
				if (twoHanded != null) {
					continue;
				}
				twoHanded = item;
			}
			equippedItems.add(item);
		}
	}

	return equippedItems;
}
 
Example #9
Source File: WorldBuffService.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public void onReturnHome(Npc npc) {
	FastList<WorldBuffTemplate> buff = worldBuff.get(npc.getWorldId());
	if (buff == null) {
		return;
	}
	for (FastList.Node<WorldBuffTemplate> n = buff.head(), end = buff.tail(); (n = n.getNext()) != end;) {
		WorldBuffTemplate bf = n.getValue();
		if (bf.getType().equals(WorldBuffType.PC)) {
			continue;
		}
		for (FastList.Node<TribeClass> t = bf.getTribe().head(), endt = bf.getTribe().tail(); (t = t.getNext()) != endt;) {
			if (npc.getTribe().equals(t.getValue())) {
				buff(bf, npc);
				break;
			}
		}
		if (!bf.getNpcIds().isEmpty() && bf.getNpcIds().contains(npc.getNpcId())) {
			buff(bf, npc);
		}
	}
}
 
Example #10
Source File: NettySctpMultiHomeTransferTest.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
public void setUp(IpChannelType ipChannelType) throws Exception {
        this.clientAssocUp = false;
        this.serverAssocUp = false;

        this.clientAssocDown = false;
        this.serverAssocDown = false;

        this.clientMessage = new FastList<String>();
        this.serverMessage = new FastList<String>();

        this.management = new NettySctpManagementImpl("server-management");
//        this.management.setSingleThread(true);
        this.management.start();
        this.management.setConnectDelay(10000);// Try connecting every 10 secs
        this.management.removeAllResourses();

        this.server = (NettyServerImpl) this.management.addServer(SERVER_NAME, SERVER_HOST, SERVER_PORT, ipChannelType, false,
                0, new String[] { SERVER_HOST1 });
        this.serverAssociation = (NettyAssociationImpl) this.management.addServerAssociation(CLIENT_HOST, CLIENT_PORT,
                SERVER_NAME, SERVER_ASSOCIATION_NAME, ipChannelType);
        this.clientAssociation = (NettyAssociationImpl) this.management.addAssociation(CLIENT_HOST, CLIENT_PORT, SERVER_HOST,
                SERVER_PORT, CLIENT_ASSOCIATION_NAME, ipChannelType, new String[] { CLIENT_HOST1 });
    }
 
Example #11
Source File: MoveTaskManager.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void run() {
	final FastList<Creature> arrivedCreatures = FastList.newInstance();
	final FastList<Creature> followingCreatures = FastList.newInstance();

	for (FastMap.Entry<Integer, Creature> e = movingCreatures.head(), mapEnd = movingCreatures.tail(); (e = e.getNext()) != mapEnd;) {
		Creature creature = e.getValue();
		creature.getMoveController().moveToDestination();
		if (creature.getAi2().poll(AIQuestion.DESTINATION_REACHED)) {
			movingCreatures.remove(e.getKey());
			arrivedCreatures.add(e.getValue());
		}
		else {
			followingCreatures.add(e.getValue());
		}
	}
	targetReachedManager.executeAll(arrivedCreatures);
	targetTooFarManager.executeAll(followingCreatures);
	FastList.recycle(arrivedCreatures);
	FastList.recycle(followingCreatures);

}
 
Example #12
Source File: AssociationImpl.java    From sctp with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Stops this Association. If the underlying SctpChannel is open, marks the
 * channel for close
 */
protected void stop() throws Exception {
	this.started = false;
	for (ManagementEventListener lstr : this.management.getManagementEventListeners()) {
		try {
			lstr.onAssociationStopped(this);
		} catch (Throwable ee) {
			logger.error("Exception while invoking onAssociationStopped", ee);
		}
	}

	if (this.getSocketChannel() != null && this.getSocketChannel().isOpen()) {
		FastList<ChangeRequest> pendingChanges = this.management.getPendingChanges();
		synchronized (pendingChanges) {
			// Indicate we want the interest ops set changed
			pendingChanges.add(new ChangeRequest(getSocketChannel(), this, ChangeRequest.CLOSE, -1));
		}

		// Finally, wake up our selecting thread so it can make the required
		// changes
		this.management.getSocketSelector().wakeup();
	}
}
 
Example #13
Source File: SM_LOOT_ITEMLIST.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public SM_LOOT_ITEMLIST(int targetObjectId, Set<DropItem> setItems, Player player) {
	this.targetObjectId = targetObjectId;
	this.dropItems = new FastList<DropItem>();
	if (setItems == null) {
		LoggerFactory.getLogger(SM_LOOT_ITEMLIST.class).warn("null Set<DropItem>, skip");
		return;
	}

	for (DropItem item : setItems) {
		if (item.getPlayerObjId() == 0 || player.getObjectId() == item.getPlayerObjId()) {
			if (DataManager.ITEM_DATA.getItemTemplate(item.getDropTemplate().getItemId()) != null) {
				dropItems.add(item);
			}
		}
	}
}
 
Example #14
Source File: HouseRegistry.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
/**
 * In packets used custom parts are not included (kinda semi-deleted)
 */
public FastList<HouseDecoration> getCustomParts() {
	FastList<HouseDecoration> temp = FastList.newInstance();
	for (HouseDecoration decor : customParts.values()) {
		if (decor.getPersistentState() != PersistentState.DELETED && !decor.isUsed()) {
			temp.add(decor);
		}
	}
	return temp;
}
 
Example #15
Source File: RewardService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void verify(Player player) {
	FastList<RewardEntryItem> list = dao.getAvailable(player.getObjectId());
	if (list.size() == 0 || player.getMailbox() == null) {
		return;
	}

	FastList<Integer> rewarded = FastList.newInstance();

	for (RewardEntryItem item : list) {
		if (DataManager.ITEM_DATA.getItemTemplate(item.id) == null) {
			log.warn("[RewardController][" + item.unique + "] null template for item " + item.id + " on player " + player.getObjectId() + ".");
			continue;
		}

		try {
			if (!SystemMailService.getInstance().sendMail("$$CASH_ITEM_MAIL", player.getName(), item.id + ", " + item.count, "0, " + (System.currentTimeMillis() / 1000) + ",", item.id, (int) item.count, 0, LetterType.BLACKCLOUD)) {
				continue;
			}
			log.info("[RewardController][" + item.unique + "] player " + player.getName() + " has received (" + item.count + ")" + item.id + ".");
			rewarded.add(item.unique);
		}
		catch (Exception e) {
			log.error("[RewardController][" + item.unique + "] failed to add item (" + item.count + ")" + item.id + " to " + player.getObjectId(), e);
			continue;
		}
	}

	if (rewarded.size() > 0) {
		dao.uncheckAvailable(rewarded);

		FastList.recycle(rewarded);
		FastList.recycle(list);
	}
}
 
Example #16
Source File: NettySctpManagementImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void removeManagementEventListener(ManagementEventListener listener) {
    synchronized (this) {
        if (!this.managementEventListeners.contains(listener))
            return;

        FastList<ManagementEventListener> newManagementEventListeners = new FastList<ManagementEventListener>();
        newManagementEventListeners.addAll(this.managementEventListeners);
        newManagementEventListeners.remove(listener);
        this.managementEventListeners = newManagementEventListeners;
    }
}
 
Example #17
Source File: SM_QUEST_COMPLETED_LIST.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void writeImpl(AionConnection con) {
	writeH(0x01); // 2.1
	writeH(-questState.size() & 0xFFFF);
	for (QuestState qs : questState) {
		writeD(qs.getQuestId());
		writeD(qs.getCompleteCount());
		writeD(1); // unk 5.6
	}
	FastList.recycle(questState);
	questState = null;
}
 
Example #18
Source File: Storage.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public FastList<Item> getItemsWithKinah() {
	FastList<Item> items = this.itemStorage.getItems();
	if (this.kinahItem != null) {
		items.add(this.kinahItem);
	}
	return items;
}
 
Example #19
Source File: ServerImpl.java    From sctp with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void stop() throws Exception {
	FastList<String> tempAssociations = associations;
	for (FastList.Node<String> n = tempAssociations.head(), end = tempAssociations.tail(); (n = n.getNext()) != end;) {
		String assocName = n.getValue();
		Association associationTemp = this.management.getAssociation(assocName);
		if (associationTemp.isStarted()) {
			throw new Exception(String.format("Stop all the associations first. Association=%s is still started",
					associationTemp.getName()));
		}
	}

	synchronized (this.anonymAssociations) {
		// stopping all anonymous associations
		for (Association ass : this.anonymAssociations) {
			ass.stopAnonymousAssociation();
		}
		this.anonymAssociations.clear();
	}

	if (this.getIpChannel() != null) {
		try {
			this.getIpChannel().close();
		} catch (Exception e) {
			logger.warn(String.format("Error while stopping the Server=%s", this.name), e);
		}
	}

	this.started = false;

	if (logger.isInfoEnabled()) {
		logger.info(String.format("Stoped Server=%s", this.name));
	}
}
 
Example #20
Source File: MySQL5SurveyControllerDAO.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
@Override
public FastList<SurveyItem> getAllNew() {
	FastList<SurveyItem> list = FastList.newInstance();

	Connection con = null;
	try {
		con = DatabaseFactory.getConnection();
		PreparedStatement stmt = con.prepareStatement(SELECT_QUERY);
		stmt.setInt(1, 0);

		ResultSet rset = stmt.executeQuery();
		while (rset.next()) {
			SurveyItem item = new SurveyItem();
			item.uniqueId = rset.getInt("unique_id");
			item.ownerId = rset.getInt("owner_id");
			item.itemId = rset.getInt("item_id");
			item.count = rset.getLong("item_count");
			item.html = rset.getString("html_text");
			item.radio = rset.getString("html_radio");
			list.add(item);
		}
		rset.close();
		stmt.close();
	}
	catch (Exception e) {
		log.warn("getAllNew() from DB: " + e.getMessage(), e);
	}
	finally {
		DatabaseFactory.close(con);
	}

	return list;
}
 
Example #21
Source File: Filter.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public List<DataStructure> filterPacketList(List<DataStructure> packets)
{
    List<DataStructure> list = new FastList<DataStructure>();
    // :)
    for(DataStructure dp : packets)
        if(this.matches(dp))
            list.add(dp);
    // i dont like when there's no { } tho, this one is beautiful :)
    return list;
}
 
Example #22
Source File: QuestStateList.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public FastList<QuestState> getAllFinishedQuests() {
	FastList<QuestState> completeQuestList = FastList.newInstance();
	for (QuestState qs : _quests.values()) {
		if (qs.getStatus() == QuestStatus.COMPLETE) {
			completeQuestList.add(qs);
		}
	}
	return completeQuestList;
}
 
Example #23
Source File: HousingService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public FastList<House> getCustomHouses() {
	FastList<House> houses = FastList.newInstance();
	for (List<House> mapHouses : housesByMapId.values()) {
		houses.addAll(mapHouses);
	}
	return houses;
}
 
Example #24
Source File: DropRegistrationService.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private DropRegistrationService() {
	init();
	noReductionMaps = new FastList<Integer>();
	for (String zone : DropConfig.DISABLE_DROP_REDUCTION_IN_ZONES.split(",")) {
		noReductionMaps.add(Integer.parseInt(zone));
	}
}
 
Example #25
Source File: Player.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
/**
 * //TODO probably need to optimize here
 *
 * @return
 */
public FastList<Item> getAllItems() {
	FastList<Item> items = FastList.newInstance();
	items.addAll(this.inventory.getItemsWithKinah());
	if (this.regularWarehouse != null) {
		items.addAll(this.regularWarehouse.getItemsWithKinah());
	}
	if (this.accountWarehouse != null) {
		items.addAll(this.accountWarehouse.getItemsWithKinah());
	}

	for (int petBagId = StorageType.PET_BAG_MIN; petBagId <= StorageType.PET_BAG_MAX; petBagId++) {
		IStorage petBag = getStorage(petBagId);
		if (petBag != null) {
			items.addAll(petBag.getItemsWithKinah());
		}
	}

	for (int houseWhId = StorageType.HOUSE_WH_MIN; houseWhId <= StorageType.HOUSE_WH_MAX; houseWhId++) {
		IStorage cabinet = getStorage(houseWhId);
		if (cabinet != null) {
			items.addAll(cabinet.getItemsWithKinah());
		}
	}

	items.addAll(getEquipment().getEquippedItems());
	return items;
}
 
Example #26
Source File: Main.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private void exportNpcSkill() {
	if (getViewerTab().getComponentCount() > 0) {

		ViewPane pane = ((Main) PacketSamurai.getUserInterface()).getViewerTab().getCurrentViewPane();
		if (pane != null) {
			String sessionName = pane.getGameSessionViewer().getSession().getSessionName();
			FastList<DataPacket> packets = pane.getGameSessionViewer().getSession().getPackets();
			new NpcSkillExporter(packets, sessionName).parse();
		}
	}
}
 
Example #27
Source File: HouseRegistry.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public FastList<HouseDecoration> getDefaultParts() {
	FastList<HouseDecoration> temp = FastList.newInstance();
	for (HouseDecoration deco : defaultParts) {
		if (deco != null) {
			temp.add(deco);
		}
	}
	return temp;
}
 
Example #28
Source File: Main.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private void exportNpcSpawns() {
	if (getViewerTab().getComponentCount() > 0) {

		ViewPane pane = ((Main) PacketSamurai.getUserInterface()).getViewerTab().getCurrentViewPane();
		if (pane != null) {
			String sessionName = pane.getGameSessionViewer().getSession().getSessionName();
			FastList<DataPacket> packets = pane.getGameSessionViewer().getSession().getPackets();
			new NpcSpawnExporter(packets, sessionName).parse();
		}
	}
}
 
Example #29
Source File: Main.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private void exportNpcInfo() {
	if (getViewerTab().getComponentCount() > 0) {

		ViewPane pane = ((Main) PacketSamurai.getUserInterface()).getViewerTab().getCurrentViewPane();
		if (pane != null) {
			String sessionName = pane.getGameSessionViewer().getSession().getSessionName();
			FastList<DataPacket> packets = pane.getGameSessionViewer().getSession().getPackets();
			new NpcInfoExporter(packets, sessionName).parse();
		}
	}
}
 
Example #30
Source File: Main.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
private void exportGatherSpawns() {
	if (getViewerTab().getComponentCount() > 0) {

		ViewPane pane = ((Main) PacketSamurai.getUserInterface()).getViewerTab().getCurrentViewPane();
		if (pane != null) {
			String sessionName = pane.getGameSessionViewer().getSession().getSessionName();
			FastList<DataPacket> packets = pane.getGameSessionViewer().getSession().getPackets();
			new NpcGatherExporter(packets, sessionName).parse();
		}
	}
}