Removed most stream filter uses.
This commit is contained in:
		| @@ -769,7 +769,15 @@ public class ClassMaster extends AbstractNpcAI implements IXmlReader | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			final ClassChangeData data = _classChangeData.stream().filter(ccd -> ccd.isInCategory(player)).findFirst().get(); | ||||
| 			ClassChangeData data = null; | ||||
| 			for (ClassChangeData ccd : _classChangeData) | ||||
| 			{ | ||||
| 				if (ccd.isInCategory(player)) | ||||
| 				{ | ||||
| 					data = ccd; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 			if (data != null) | ||||
| 			{ | ||||
| 				// Required items. | ||||
| @@ -1066,11 +1074,35 @@ public class ClassMaster extends AbstractNpcAI implements IXmlReader | ||||
| 	 | ||||
| 	private boolean checkIfClassChangeHasOptions(PlayerInstance player) | ||||
| 	{ | ||||
| 		boolean showOptions = _classChangeData.stream().filter(ccd -> !ccd.getItemsRequired().isEmpty()).anyMatch(ccd -> ccd.isInCategory(player)); // Check if there are requirements | ||||
| 		boolean showOptions = false; | ||||
| 		 | ||||
| 		// Check if there are requirements | ||||
| 		for (ClassChangeData ccd : _classChangeData) | ||||
| 		{ | ||||
| 			if (!ccd.getItemsRequired().isEmpty() && ccd.isInCategory(player)) | ||||
| 			{ | ||||
| 				showOptions = true; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (!showOptions) | ||||
| 		{ | ||||
| 			showOptions = _classChangeData.stream().filter(ccd -> !ccd.getItemsRewarded().isEmpty()).filter(ccd -> ccd.isInCategory(player)).count() > 1; // Check if there is more than 1 reward to chose. | ||||
| 			// Check if there is more than 1 reward to chose. | ||||
| 			int count = 0; | ||||
| 			for (ClassChangeData ccd : _classChangeData) | ||||
| 			{ | ||||
| 				if (!ccd.getItemsRewarded().isEmpty() && ccd.isInCategory(player)) | ||||
| 				{ | ||||
| 					count++; | ||||
| 				} | ||||
| 			} | ||||
| 			if (count > 1) | ||||
| 			{ | ||||
| 				showOptions = true; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		return showOptions; | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -216,12 +216,15 @@ public class SellBuff implements IVoicedCommandHandler, IBypassHandler | ||||
| 						return false; | ||||
| 					} | ||||
| 					 | ||||
| 					final SellBuffHolder holder = player.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToChange.getId())).findFirst().orElse(null); | ||||
| 					if ((holder != null)) | ||||
| 					for (SellBuffHolder holder : player.getSellingBuffs()) | ||||
| 					{ | ||||
| 						player.sendMessage("Price of " + player.getKnownSkill(holder.getSkillId()).getName() + " has been changed to " + price + "!"); | ||||
| 						holder.setPrice(price); | ||||
| 						SellBuffsManager.getInstance().sendBuffEditMenu(player); | ||||
| 						if (holder.getSkillId() == skillToChange.getId()) | ||||
| 						{ | ||||
| 							player.sendMessage("Price of " + player.getKnownSkill(holder.getSkillId()).getName() + " has been changed to " + price + "!"); | ||||
| 							holder.setPrice(price); | ||||
| 							SellBuffsManager.getInstance().sendBuffEditMenu(player); | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| @@ -250,11 +253,14 @@ public class SellBuff implements IVoicedCommandHandler, IBypassHandler | ||||
| 						return false; | ||||
| 					} | ||||
| 					 | ||||
| 					final SellBuffHolder holder = player.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToRemove.getId())).findFirst().orElse(null); | ||||
| 					if ((holder != null) && player.getSellingBuffs().remove(holder)) | ||||
| 					for (SellBuffHolder holder : player.getSellingBuffs()) | ||||
| 					{ | ||||
| 						player.sendMessage("Skill " + player.getKnownSkill(holder.getSkillId()).getName() + " has been removed!"); | ||||
| 						SellBuffsManager.getInstance().sendBuffEditMenu(player); | ||||
| 						if ((holder.getSkillId() == skillToRemove.getId()) && player.getSellingBuffs().remove(holder)) | ||||
| 						{ | ||||
| 							player.sendMessage("Skill " + player.getKnownSkill(holder.getSkillId()).getName() + " has been removed!"); | ||||
| 							SellBuffsManager.getInstance().sendBuffEditMenu(player); | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| @@ -399,29 +405,33 @@ public class SellBuff implements IVoicedCommandHandler, IBypassHandler | ||||
| 						return false; | ||||
| 					} | ||||
| 					 | ||||
| 					final SellBuffHolder holder = seller.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skillToBuy.getId())).findFirst().orElse(null); | ||||
| 					if (holder != null) | ||||
| 					for (SellBuffHolder holder : player.getSellingBuffs()) | ||||
| 					{ | ||||
| 						if (AbstractScript.getQuestItemsCount(player, Config.SELLBUFF_PAYMENT_ID) >= holder.getPrice()) | ||||
| 						if (holder.getSkillId() == skillToBuy.getId()) | ||||
| 						{ | ||||
| 							AbstractScript.takeItems(player, Config.SELLBUFF_PAYMENT_ID, holder.getPrice()); | ||||
| 							AbstractScript.giveItems(seller, Config.SELLBUFF_PAYMENT_ID, holder.getPrice()); | ||||
| 							seller.reduceCurrentMp(skillToBuy.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER); | ||||
| 							skillToBuy.activateSkill(seller, player); | ||||
| 						} | ||||
| 						else | ||||
| 						{ | ||||
| 							final Item item = ItemTable.getInstance().getTemplate(Config.SELLBUFF_PAYMENT_ID); | ||||
| 							if (item != null) | ||||
| 							if (AbstractScript.getQuestItemsCount(player, Config.SELLBUFF_PAYMENT_ID) >= holder.getPrice()) | ||||
| 							{ | ||||
| 								player.sendMessage("Not enough " + item.getName() + "!"); | ||||
| 								AbstractScript.takeItems(player, Config.SELLBUFF_PAYMENT_ID, holder.getPrice()); | ||||
| 								AbstractScript.giveItems(seller, Config.SELLBUFF_PAYMENT_ID, holder.getPrice()); | ||||
| 								seller.reduceCurrentMp(skillToBuy.getMpConsume() * Config.SELLBUFF_MP_MULTIPLER); | ||||
| 								skillToBuy.activateSkill(seller, player); | ||||
| 							} | ||||
| 							else | ||||
| 							{ | ||||
| 								player.sendMessage("Not enough items!"); | ||||
| 								final Item item = ItemTable.getInstance().getTemplate(Config.SELLBUFF_PAYMENT_ID); | ||||
| 								if (item != null) | ||||
| 								{ | ||||
| 									player.sendMessage("Not enough " + item.getName() + "!"); | ||||
| 								} | ||||
| 								else | ||||
| 								{ | ||||
| 									player.sendMessage("Not enough items!"); | ||||
| 								} | ||||
| 							} | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 					 | ||||
| 					SellBuffsManager.getInstance().sendBuffMenu(player, seller, index); | ||||
| 				} | ||||
| 				break; | ||||
|   | ||||
| @@ -297,7 +297,13 @@ public class AdminAdmin implements IAdminCommandHandler | ||||
| 					} | ||||
| 					 | ||||
| 					final CreatureSay cs = new CreatureSay(activeChar, ChatType.WORLD, activeChar.getName(), sb.toString()); | ||||
| 					World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo); | ||||
| 					for (PlayerInstance player : World.getInstance().getPlayers()) | ||||
| 					{ | ||||
| 						if (player.isNotBlocked(activeChar)) | ||||
| 						{ | ||||
| 							cs.sendTo(player); | ||||
| 						} | ||||
| 					} | ||||
| 					break; | ||||
| 				} | ||||
| 				case "see": | ||||
|   | ||||
| @@ -98,16 +98,34 @@ public class ChatWorld implements IChatHandler | ||||
| 			{ | ||||
| 				if (activeChar.isGood()) | ||||
| 				{ | ||||
| 					World.getInstance().getAllGoodPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo); | ||||
| 					for (PlayerInstance player : World.getInstance().getAllGoodPlayers()) | ||||
| 					{ | ||||
| 						if (player.isNotBlocked(activeChar)) | ||||
| 						{ | ||||
| 							cs.sendTo(player); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				if (activeChar.isEvil()) | ||||
| 				{ | ||||
| 					World.getInstance().getAllEvilPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo); | ||||
| 					for (PlayerInstance player : World.getInstance().getAllEvilPlayers()) | ||||
| 					{ | ||||
| 						if (player.isNotBlocked(activeChar)) | ||||
| 						{ | ||||
| 							cs.sendTo(player); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo); | ||||
| 				for (PlayerInstance player : World.getInstance().getPlayers()) | ||||
| 				{ | ||||
| 					if (player.isNotBlocked(activeChar)) | ||||
| 					{ | ||||
| 						cs.sendTo(player); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			activeChar.setWorldChatUsed(activeChar.getWorldChatUsed() + 1); | ||||
|   | ||||
| @@ -215,16 +215,19 @@ public class HomeBoard implements IParseBoardHandler | ||||
| 					{ | ||||
| 						continue; | ||||
| 					} | ||||
| 					targets.stream().filter(target -> !target.isSummon() || !skill.isSharedWithSummon()).forEach(target -> | ||||
| 					for (Creature target : targets) | ||||
| 					{ | ||||
| 						skill.applyEffects(player, target); | ||||
| 						if (Config.COMMUNITYBOARD_CAST_ANIMATIONS) | ||||
| 						if (skill.isSharedWithSummon() || target.isPlayer()) | ||||
| 						{ | ||||
| 							player.sendPacket(new MagicSkillUse(player, target, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay())); | ||||
| 							// not recommend broadcast | ||||
| 							// player.broadcastPacket(new MagicSkillUse(player, target, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay())); | ||||
| 							skill.applyEffects(player, target); | ||||
| 							if (Config.COMMUNITYBOARD_CAST_ANIMATIONS) | ||||
| 							{ | ||||
| 								player.sendPacket(new MagicSkillUse(player, target, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay())); | ||||
| 								// not recommend broadcast | ||||
| 								// player.broadcastPacket(new MagicSkillUse(player, target, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay())); | ||||
| 							} | ||||
| 						} | ||||
| 					}); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
|   | ||||
| @@ -88,7 +88,13 @@ public class BossDailyMissionHandler extends AbstractDailyMissionHandler | ||||
| 			{ | ||||
| 				final CommandChannel channel = party.getCommandChannel(); | ||||
| 				final List<PlayerInstance> members = channel != null ? channel.getMembers() : party.getMembers(); | ||||
| 				members.stream().filter(member -> member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE).forEach(this::processPlayerProgress); | ||||
| 				for (PlayerInstance member : members) | ||||
| 				{ | ||||
| 					if (member.calculateDistance3D(monster) <= Config.ALT_PARTY_RANGE) | ||||
| 					{ | ||||
| 						processPlayerProgress(member); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
|   | ||||
| @@ -18,15 +18,14 @@ package handlers.effecthandlers; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.HashSet; | ||||
| import java.util.Objects; | ||||
| import java.util.Set; | ||||
|  | ||||
| import org.l2jmobius.gameserver.model.StatSet; | ||||
| import org.l2jmobius.gameserver.model.WorldObject; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| import org.l2jmobius.gameserver.model.effects.AbstractEffect; | ||||
| import org.l2jmobius.gameserver.model.items.instance.ItemInstance; | ||||
| import org.l2jmobius.gameserver.model.skills.AbnormalType; | ||||
| import org.l2jmobius.gameserver.model.skills.BuffInfo; | ||||
| import org.l2jmobius.gameserver.model.skills.Skill; | ||||
| import org.l2jmobius.gameserver.network.serverpackets.AbnormalStatusUpdate; | ||||
| import org.l2jmobius.gameserver.network.serverpackets.ExAbnormalStatusUpdateFromTarget; | ||||
| @@ -94,19 +93,25 @@ public class AbnormalTimeChange extends AbstractEffect | ||||
| 			{ | ||||
| 				if (_abnormals.isEmpty()) | ||||
| 				{ | ||||
| 					effected.getEffectList().getEffects().stream().filter(b -> b.getSkill().canBeDispelled()).forEach(b -> | ||||
| 					for (BuffInfo info : effected.getEffectList().getEffects()) | ||||
| 					{ | ||||
| 						b.resetAbnormalTime(b.getTime() + _time); | ||||
| 						asu.addSkill(b); | ||||
| 					}); | ||||
| 						if (info.getSkill().canBeDispelled()) | ||||
| 						{ | ||||
| 							info.resetAbnormalTime(info.getTime() + _time); | ||||
| 							asu.addSkill(info); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					effected.getEffectList().getEffects().stream().filter(b -> b.getSkill().canBeDispelled() && _abnormals.contains(b.getSkill().getAbnormalType())).forEach(b -> | ||||
| 					for (BuffInfo info : effected.getEffectList().getEffects()) | ||||
| 					{ | ||||
| 						b.resetAbnormalTime(b.getTime() + _time); | ||||
| 						asu.addSkill(b); | ||||
| 					}); | ||||
| 						if (info.getSkill().canBeDispelled() && _abnormals.contains(info.getSkill().getAbnormalType())) | ||||
| 						{ | ||||
| 							info.resetAbnormalTime(info.getTime() + _time); | ||||
| 							asu.addSkill(info); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| 			} | ||||
| @@ -114,19 +119,25 @@ public class AbnormalTimeChange extends AbstractEffect | ||||
| 			{ | ||||
| 				if (_abnormals.isEmpty()) | ||||
| 				{ | ||||
| 					effected.getEffectList().getDebuffs().stream().filter(b -> b.getSkill().canBeDispelled()).forEach(b -> | ||||
| 					for (BuffInfo info : effected.getEffectList().getDebuffs()) | ||||
| 					{ | ||||
| 						b.resetAbnormalTime(b.getAbnormalTime()); | ||||
| 						asu.addSkill(b); | ||||
| 					}); | ||||
| 						if (info.getSkill().canBeDispelled()) | ||||
| 						{ | ||||
| 							info.resetAbnormalTime(info.getAbnormalTime()); | ||||
| 							asu.addSkill(info); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					effected.getEffectList().getDebuffs().stream().filter(b -> b.getSkill().canBeDispelled() && _abnormals.contains(b.getSkill().getAbnormalType())).forEach(b -> | ||||
| 					for (BuffInfo info : effected.getEffectList().getDebuffs()) | ||||
| 					{ | ||||
| 						b.resetAbnormalTime(b.getAbnormalTime()); | ||||
| 						asu.addSkill(b); | ||||
| 					}); | ||||
| 						if (info.getSkill().canBeDispelled() && _abnormals.contains(info.getSkill().getAbnormalType())) | ||||
| 						{ | ||||
| 							info.resetAbnormalTime(info.getAbnormalTime()); | ||||
| 							asu.addSkill(info); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| 			} | ||||
| @@ -135,14 +146,13 @@ public class AbnormalTimeChange extends AbstractEffect | ||||
| 		effected.sendPacket(asu); | ||||
| 		 | ||||
| 		final ExAbnormalStatusUpdateFromTarget upd = new ExAbnormalStatusUpdateFromTarget(effected); | ||||
| 		 | ||||
| 		// @formatter:off | ||||
| 		effected.getStatus().getStatusListener().stream() | ||||
| 			.filter(Objects::nonNull) | ||||
| 			.filter(WorldObject::isPlayer) | ||||
| 			.map(Creature::getActingPlayer) | ||||
| 			.forEach(upd::sendTo); | ||||
| 		// @formatter:on | ||||
| 		for (Creature creature : effected.getStatus().getStatusListener()) | ||||
| 		{ | ||||
| 			if ((creature != null) && creature.isPlayer()) | ||||
| 			{ | ||||
| 				upd.sendTo(creature.getActingPlayer()); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (effected.isPlayer() && (effected.getTarget() == effected)) | ||||
| 		{ | ||||
|   | ||||
| @@ -52,7 +52,13 @@ public class CallTargetParty extends AbstractEffect | ||||
| 		final Party party = player.getParty(); | ||||
| 		if (party != null) | ||||
| 		{ | ||||
| 			party.getMembers().stream().filter(p -> (p != player) && CallPc.checkSummonTargetStatus(p, effector)).forEach(p -> p.teleToLocation(player.getLocation(), true)); | ||||
| 			for (PlayerInstance member : party.getMembers()) | ||||
| 			{ | ||||
| 				if ((member != player) && CallPc.checkSummonTargetStatus(member, effector)) | ||||
| 				{ | ||||
| 					member.teleToLocation(player.getLocation(), true); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -173,7 +173,13 @@ public class SummonNpc extends AbstractEffect | ||||
| 				// If only single instance is allowed, delete previous NPCs. | ||||
| 				if (_singleInstance) | ||||
| 				{ | ||||
| 					player.getSummonedNpcs().stream().filter(npc -> npc.getId() == _npcId).forEach(Npc::deleteMe); | ||||
| 					for (Npc npc : player.getSummonedNpcs()) | ||||
| 					{ | ||||
| 						if (npc.getId() == _npcId) | ||||
| 						{ | ||||
| 							npc.deleteMe(); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				 | ||||
| 				final Npc npc = spawn.doSpawn(_isSummonSpawn); | ||||
|   | ||||
| @@ -93,13 +93,19 @@ public class Synergy extends AbstractEffect | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		final int abnormalCount = (int) _optionalSlots.stream().filter(effector::hasAbnormalType).count(); | ||||
| 		int abnormalCount = 0; | ||||
| 		for (AbnormalType abnormalType : _optionalSlots) | ||||
| 		{ | ||||
| 			if (effector.hasAbnormalType(abnormalType)) | ||||
| 			{ | ||||
| 				abnormalCount++; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (abnormalCount >= _minSlot) | ||||
| 		{ | ||||
| 			final SkillHolder partyBuff = new SkillHolder(_partyBuffSkillId, Math.max(abnormalCount - 1, _skillLevelScaleTo)); | ||||
| 			final SkillHolder partyBuff = new SkillHolder(_partyBuffSkillId, Math.min(abnormalCount - 1, _skillLevelScaleTo)); | ||||
| 			final Skill partyBuffSkill = partyBuff.getSkill(); | ||||
| 			 | ||||
| 			if (partyBuffSkill != null) | ||||
| 			{ | ||||
| 				final WorldObject target = partyBuffSkill.getTarget(effector, effected, false, false, false); | ||||
|   | ||||
| @@ -20,6 +20,8 @@ import org.l2jmobius.gameserver.ai.CtrlIntention; | ||||
| import org.l2jmobius.gameserver.model.Party; | ||||
| import org.l2jmobius.gameserver.model.StatSet; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| import org.l2jmobius.gameserver.model.actor.Npc; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.model.effects.AbstractEffect; | ||||
| import org.l2jmobius.gameserver.model.effects.EffectType; | ||||
| import org.l2jmobius.gameserver.model.interfaces.ILocational; | ||||
| @@ -59,13 +61,24 @@ public class TeleportToNpc extends AbstractEffect | ||||
| 	@Override | ||||
| 	public void instant(Creature effector, Creature effected, Skill skill, ItemInstance item) | ||||
| 	{ | ||||
| 		final ILocational teleLocation = effector.getSummonedNpcs().stream().filter(npc -> npc.getId() == _npcId).findAny().orElse(null); | ||||
| 		ILocational teleLocation = null; | ||||
| 		for (Npc npc : effector.getSummonedNpcs()) | ||||
| 		{ | ||||
| 			if (npc.getId() == _npcId) | ||||
| 			{ | ||||
| 				teleLocation = npc; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (teleLocation != null) | ||||
| 		{ | ||||
| 			final Party party = effected.getParty(); | ||||
| 			if (_party && (party != null)) | ||||
| 			{ | ||||
| 				party.getMembers().forEach(p -> teleport(p, teleLocation)); | ||||
| 				for (PlayerInstance member : party.getMembers()) | ||||
| 				{ | ||||
| 					teleport(member, teleLocation); | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
|   | ||||
| @@ -16,8 +16,8 @@ | ||||
|  */ | ||||
| package handlers.itemhandlers; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.gameserver.enums.ItemSkillType; | ||||
| import org.l2jmobius.gameserver.enums.ShotType; | ||||
| @@ -60,7 +60,15 @@ public class BeastSoulShot implements IItemHandler | ||||
| 			return false; | ||||
| 		} | ||||
| 		 | ||||
| 		final List<Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList()); | ||||
| 		final List<Summon> aliveServitor = new ArrayList<>(); | ||||
| 		for (Summon s : playable.getServitors().values()) | ||||
| 		{ | ||||
| 			if (!s.isDead()) | ||||
| 			{ | ||||
| 				aliveServitor.add(s); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if ((pet == null) && aliveServitor.isEmpty()) | ||||
| 		{ | ||||
| 			activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_SERVITOR_SAD_ISN_T_IT); | ||||
|   | ||||
| @@ -16,8 +16,8 @@ | ||||
|  */ | ||||
| package handlers.itemhandlers; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.gameserver.enums.ItemSkillType; | ||||
| import org.l2jmobius.gameserver.enums.ShotType; | ||||
| @@ -60,7 +60,15 @@ public class BeastSpiritShot implements IItemHandler | ||||
| 			return false; | ||||
| 		} | ||||
| 		 | ||||
| 		final List<Summon> aliveServitor = playable.getServitors().values().stream().filter(s -> !s.isDead()).collect(Collectors.toList()); | ||||
| 		final List<Summon> aliveServitor = new ArrayList<>(); | ||||
| 		for (Summon s : playable.getServitors().values()) | ||||
| 		{ | ||||
| 			if (!s.isDead()) | ||||
| 			{ | ||||
| 				aliveServitor.add(s); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if ((pet == null) && aliveServitor.isEmpty()) | ||||
| 		{ | ||||
| 			activeOwner.sendPacket(SystemMessageId.SOULSHOTS_AND_SPIRITSHOTS_ARE_NOT_AVAILABLE_FOR_A_DEAD_SERVITOR_SAD_ISN_T_IT); | ||||
|   | ||||
| @@ -18,6 +18,7 @@ package handlers.playeractions; | ||||
|  | ||||
| import org.l2jmobius.gameserver.handler.IPlayerActionHandler; | ||||
| import org.l2jmobius.gameserver.model.ActionDataHolder; | ||||
| import org.l2jmobius.gameserver.model.actor.Summon; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.network.SystemMessageId; | ||||
|  | ||||
| @@ -32,7 +33,13 @@ public class ServitorAttack implements IPlayerActionHandler | ||||
| 	{ | ||||
| 		if (player.hasServitors()) | ||||
| 		{ | ||||
| 			player.getServitors().values().stream().filter(s -> s.canAttack(player.getTarget(), ctrlPressed)).forEach(s -> s.doAttack(player.getTarget())); | ||||
| 			for (Summon summon : player.getServitors().values()) | ||||
| 			{ | ||||
| 				if (summon.canAttack(player.getTarget(), ctrlPressed)) | ||||
| 				{ | ||||
| 					summon.doAttack(player.getTarget()); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
|   | ||||
| @@ -19,6 +19,7 @@ package handlers.playeractions; | ||||
| import org.l2jmobius.gameserver.ai.CtrlIntention; | ||||
| import org.l2jmobius.gameserver.handler.IPlayerActionHandler; | ||||
| import org.l2jmobius.gameserver.model.ActionDataHolder; | ||||
| import org.l2jmobius.gameserver.model.actor.Summon; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.network.SystemMessageId; | ||||
|  | ||||
| @@ -39,17 +40,20 @@ public class ServitorMove implements IPlayerActionHandler | ||||
| 		 | ||||
| 		if (player.getTarget() != null) | ||||
| 		{ | ||||
| 			player.getServitors().values().stream().filter(s -> (s != player.getTarget()) && !s.isMovementDisabled()).forEach(s -> | ||||
| 			for (Summon summon : player.getServitors().values()) | ||||
| 			{ | ||||
| 				if (s.isBetrayed()) | ||||
| 				if ((summon != player.getTarget()) && !summon.isMovementDisabled()) | ||||
| 				{ | ||||
| 					player.sendPacket(SystemMessageId.YOUR_SERVITOR_IS_UNRESPONSIVE_AND_WILL_NOT_OBEY_ANY_ORDERS); | ||||
| 					return; | ||||
| 					if (summon.isBetrayed()) | ||||
| 					{ | ||||
| 						player.sendPacket(SystemMessageId.YOUR_SERVITOR_IS_UNRESPONSIVE_AND_WILL_NOT_OBEY_ANY_ORDERS); | ||||
| 						return; | ||||
| 					} | ||||
| 					 | ||||
| 					summon.setFollowStatus(false); | ||||
| 					summon.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, player.getTarget().getLocation()); | ||||
| 				} | ||||
| 				 | ||||
| 				s.setFollowStatus(false); | ||||
| 				s.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, player.getTarget().getLocation()); | ||||
| 			}); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -40,7 +40,6 @@ import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.database.DatabaseFactory; | ||||
| @@ -283,7 +282,14 @@ public class LoginServerThread extends Thread | ||||
| 								st.addAttribute(ServerStatus.SERVER_AGE, ServerStatus.SERVER_AGE_ALL); | ||||
| 							} | ||||
| 							sendPacket(st); | ||||
| 							final List<String> playerList = World.getInstance().getPlayers().stream().filter(player -> !player.isInOfflineMode()).map(PlayerInstance::getAccountName).collect(Collectors.toList()); | ||||
| 							final List<String> playerList = new ArrayList<>(); | ||||
| 							for (PlayerInstance player : World.getInstance().getPlayers()) | ||||
| 							{ | ||||
| 								if (!player.isInOfflineMode()) | ||||
| 								{ | ||||
| 									playerList.add(player.getAccountName()); | ||||
| 								} | ||||
| 							} | ||||
| 							if (!playerList.isEmpty()) | ||||
| 							{ | ||||
| 								sendPacket(new PlayerInGame(playerList)); | ||||
|   | ||||
| @@ -26,6 +26,7 @@ import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_REST; | ||||
|  | ||||
| import org.l2jmobius.gameserver.model.WorldObject; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| import org.l2jmobius.gameserver.model.actor.Summon; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.StaticObjectInstance; | ||||
| import org.l2jmobius.gameserver.model.interfaces.ILocational; | ||||
| @@ -164,7 +165,13 @@ public class PlayerAI extends PlayableAI | ||||
| 		// Summons in defending mode defend its master when attacked. | ||||
| 		if (_actor.getActingPlayer().hasServitors()) | ||||
| 		{ | ||||
| 			_actor.getActingPlayer().getServitors().values().stream().filter(summon -> ((SummonAI) summon.getAI()).isDefending()).forEach(summon -> ((SummonAI) summon.getAI()).defendAttack(attacker)); | ||||
| 			for (Summon summon : _actor.getActingPlayer().getServitors().values()) | ||||
| 			{ | ||||
| 				if (((SummonAI) summon.getAI()).isDefending()) | ||||
| 				{ | ||||
| 					((SummonAI) summon.getAI()).defendAttack(attacker); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| @@ -176,7 +183,13 @@ public class PlayerAI extends PlayableAI | ||||
| 		// Summons in defending mode defend its master when attacked. | ||||
| 		if (_actor.getActingPlayer().hasServitors()) | ||||
| 		{ | ||||
| 			_actor.getActingPlayer().getServitors().values().stream().filter(summon -> ((SummonAI) summon.getAI()).isDefending()).forEach(summon -> ((SummonAI) summon.getAI()).defendAttack(attacker)); | ||||
| 			for (Summon summon : _actor.getActingPlayer().getServitors().values()) | ||||
| 			{ | ||||
| 				if (((SummonAI) summon.getAI()).isDefending()) | ||||
| 				{ | ||||
| 					((SummonAI) summon.getAI()).defendAttack(attacker); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -250,10 +250,16 @@ public class SummonAI extends PlayableAI implements Runnable | ||||
| 	 | ||||
| 	private void allServitorsDefend(Creature attacker) | ||||
| 	{ | ||||
| 		final Creature Owner = getActor().getOwner(); | ||||
| 		if ((Owner != null) && Owner.getActingPlayer().hasServitors()) | ||||
| 		final Creature owner = getActor().getOwner(); | ||||
| 		if ((owner != null) && owner.getActingPlayer().hasServitors()) | ||||
| 		{ | ||||
| 			Owner.getActingPlayer().getServitors().values().stream().filter(summon -> ((SummonAI) summon.getAI()).isDefending()).forEach(summon -> ((SummonAI) summon.getAI()).defendAttack(attacker)); | ||||
| 			for (Summon summon : owner.getActingPlayer().getServitors().values()) | ||||
| 			{ | ||||
| 				if (((SummonAI) summon.getAI()).isDefending()) | ||||
| 				{ | ||||
| 					((SummonAI) summon.getAI()).defendAttack(attacker); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
|   | ||||
| @@ -203,7 +203,14 @@ public class Forum | ||||
| 	public Forum getChildByName(String name) | ||||
| 	{ | ||||
| 		vload(); | ||||
| 		return _children.stream().filter(f -> f.getName().equals(name)).findFirst().orElse(null); | ||||
| 		for (Forum f : _children) | ||||
| 		{ | ||||
| 			if (f.getName().equals(name)) | ||||
| 			{ | ||||
| 				return f; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -138,7 +138,14 @@ public class ClanTable | ||||
| 	 | ||||
| 	public Clan getClanByName(String clanName) | ||||
| 	{ | ||||
| 		return _clans.values().stream().filter(c -> c.getName().equalsIgnoreCase(clanName)).findFirst().orElse(null); | ||||
| 		for (Clan clan : _clans.values()) | ||||
| 		{ | ||||
| 			if (clan.getName().equalsIgnoreCase(clanName)) | ||||
| 			{ | ||||
| 				return clan; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -48,7 +48,15 @@ public class ActionData implements IXmlReader | ||||
| 		_actionData.clear(); | ||||
| 		_actionSkillsData.clear(); | ||||
| 		parseDatapackFile("data/ActionData.xml"); | ||||
| 		_actionData.values().stream().filter(h -> h.getHandler().equals("PetSkillUse") || h.getHandler().equals("ServitorSkillUse")).forEach(h -> _actionSkillsData.put(h.getOptionId(), h.getId())); | ||||
| 		 | ||||
| 		for (ActionDataHolder holder : _actionData.values()) | ||||
| 		{ | ||||
| 			if (holder.getHandler().equals("PetSkillUse") || holder.getHandler().equals("ServitorSkillUse")) | ||||
| 			{ | ||||
| 				_actionSkillsData.put(holder.getOptionId(), holder.getId()); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		LOGGER.info(getClass().getSimpleName() + ": Loaded " + _actionData.size() + " player actions."); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.w3c.dom.Document; | ||||
| import org.w3c.dom.NamedNodeMap; | ||||
| @@ -115,7 +114,18 @@ public class CastleData implements IXmlReader | ||||
| 	 | ||||
| 	public List<CastleSpawnHolder> getSpawnsForSide(int castleId, CastleSide side) | ||||
| 	{ | ||||
| 		return _spawns.getOrDefault(castleId, Collections.emptyList()).stream().filter(s -> s.getSide() == side).collect(Collectors.toList()); | ||||
| 		final List<CastleSpawnHolder> result = new ArrayList<>(); | ||||
| 		if (_spawns.containsKey(castleId)) | ||||
| 		{ | ||||
| 			for (CastleSpawnHolder spawn : _spawns.get(castleId)) | ||||
| 			{ | ||||
| 				if (spawn.getSide() == side) | ||||
| 				{ | ||||
| 					result.add(spawn); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<SiegeGuardHolder> getSiegeGuardsForCastle(int castleId) | ||||
|   | ||||
| @@ -175,18 +175,39 @@ public class ClanHallData implements IXmlReader | ||||
| 	 | ||||
| 	public ClanHall getClanHallByNpcId(int npcId) | ||||
| 	{ | ||||
| 		return _clanHalls.values().stream().filter(ch -> ch.getNpcs().contains(npcId)).findFirst().orElse(null); | ||||
| 		for (ClanHall ch : _clanHalls.values()) | ||||
| 		{ | ||||
| 			if (ch.getNpcs().contains(npcId)) | ||||
| 			{ | ||||
| 				return ch; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public ClanHall getClanHallByClan(Clan clan) | ||||
| 	{ | ||||
| 		return _clanHalls.values().stream().filter(ch -> ch.getOwner() == clan).findFirst().orElse(null); | ||||
| 		for (ClanHall ch : _clanHalls.values()) | ||||
| 		{ | ||||
| 			if (ch.getOwner() == clan) | ||||
| 			{ | ||||
| 				return ch; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public ClanHall getClanHallByDoorId(int doorId) | ||||
| 	{ | ||||
| 		final DoorInstance door = DoorData.getInstance().getDoor(doorId); | ||||
| 		return _clanHalls.values().stream().filter(ch -> ch.getDoors().contains(door)).findFirst().orElse(null); | ||||
| 		for (ClanHall ch : _clanHalls.values()) | ||||
| 		{ | ||||
| 			if (ch.getDoors().contains(door)) | ||||
| 			{ | ||||
| 				return ch; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<ClanHall> getFreeAuctionableHall() | ||||
|   | ||||
| @@ -20,7 +20,6 @@ import java.io.File; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.w3c.dom.Document; | ||||
|  | ||||
| @@ -86,17 +85,40 @@ public class CombinationItemsData implements IXmlReader | ||||
| 	 | ||||
| 	public CombinationItem getItemsBySlots(int firstSlot, int secondSlot) | ||||
| 	{ | ||||
| 		return _items.stream().filter(item -> (item.getItemOne() == firstSlot) && (item.getItemTwo() == secondSlot)).findFirst().orElse(null); | ||||
| 		for (CombinationItem item : _items) | ||||
| 		{ | ||||
| 			if ((item.getItemOne() == firstSlot) && (item.getItemTwo() == secondSlot)) | ||||
| 			{ | ||||
| 				return item; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<CombinationItem> getItemsByFirstSlot(int id) | ||||
| 	{ | ||||
| 		return _items.stream().filter(item -> item.getItemOne() == id).collect(Collectors.toList()); | ||||
| 		final List<CombinationItem> result = new ArrayList<>(); | ||||
| 		for (CombinationItem item : _items) | ||||
| 		{ | ||||
| 			if (item.getItemOne() == id) | ||||
| 			{ | ||||
| 				result.add(item); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<CombinationItem> getItemsBySecondSlot(int id) | ||||
| 	{ | ||||
| 		return _items.stream().filter(item -> item.getItemTwo() == id).collect(Collectors.toList()); | ||||
| 		final List<CombinationItem> result = new ArrayList<>(); | ||||
| 		for (CombinationItem item : _items) | ||||
| 		{ | ||||
| 			if (item.getItemTwo() == id) | ||||
| 			{ | ||||
| 				result.add(item); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public static final CombinationItemsData getInstance() | ||||
|   | ||||
| @@ -30,7 +30,6 @@ import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.function.Predicate; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.w3c.dom.Document; | ||||
| import org.w3c.dom.NamedNodeMap; | ||||
| @@ -742,11 +741,15 @@ public class NpcData implements IXmlReader | ||||
| 	 */ | ||||
| 	public List<NpcTemplate> getTemplates(Predicate<NpcTemplate> filter) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 			return _npcs.values().stream() | ||||
| 			.filter(filter) | ||||
| 			.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		final List<NpcTemplate> result = new ArrayList<>(); | ||||
| 		for (NpcTemplate npcTemplate : _npcs.values()) | ||||
| 		{ | ||||
| 			if (filter.test(npcTemplate)) | ||||
| 			{ | ||||
| 				result.add(npcTemplate); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.data.xml.impl; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| @@ -89,7 +88,17 @@ public class ResidenceFunctionsData implements IXmlReader | ||||
| 	 */ | ||||
| 	public ResidenceFunctionTemplate getFunction(int id, int level) | ||||
| 	{ | ||||
| 		return _functions.getOrDefault(id, Collections.emptyList()).stream().filter(template -> template.getLevel() == level).findAny().orElse(null); | ||||
| 		if (_functions.containsKey(id)) | ||||
| 		{ | ||||
| 			for (ResidenceFunctionTemplate template : _functions.get(id)) | ||||
| 			{ | ||||
| 				if (template.getLevel() == level) | ||||
| 				{ | ||||
| 					return template; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -31,7 +31,6 @@ import java.util.Map.Entry; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.w3c.dom.Document; | ||||
| import org.w3c.dom.NamedNodeMap; | ||||
| @@ -561,7 +560,12 @@ public class SkillTreeData implements IXmlReader | ||||
| 	 */ | ||||
| 	public List<Skill> getNobleSkillTree() | ||||
| 	{ | ||||
| 		return _nobleSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList()); | ||||
| 		final List<Skill> result = new ArrayList<>(); | ||||
| 		for (SkillLearn skill : _nobleSkillTree.values()) | ||||
| 		{ | ||||
| 			result.add(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel())); | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -570,7 +574,15 @@ public class SkillTreeData implements IXmlReader | ||||
| 	 */ | ||||
| 	public List<Skill> getNobleSkillAutoGetTree() | ||||
| 	{ | ||||
| 		return _nobleSkillTree.values().stream().filter(entry -> entry.isAutoGet()).map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList()); | ||||
| 		final List<Skill> result = new ArrayList<>(); | ||||
| 		for (SkillLearn skill : _nobleSkillTree.values()) | ||||
| 		{ | ||||
| 			if (skill.isAutoGet()) | ||||
| 			{ | ||||
| 				result.add(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel())); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -579,7 +591,12 @@ public class SkillTreeData implements IXmlReader | ||||
| 	 */ | ||||
| 	public List<Skill> getHeroSkillTree() | ||||
| 	{ | ||||
| 		return _heroSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList()); | ||||
| 		final List<Skill> result = new ArrayList<>(); | ||||
| 		for (SkillLearn skill : _heroSkillTree.values()) | ||||
| 		{ | ||||
| 			result.add(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel())); | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -588,7 +605,12 @@ public class SkillTreeData implements IXmlReader | ||||
| 	 */ | ||||
| 	public List<Skill> getGMSkillTree() | ||||
| 	{ | ||||
| 		return _gameMasterSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList()); | ||||
| 		final List<Skill> result = new ArrayList<>(); | ||||
| 		for (SkillLearn skill : _gameMasterSkillTree.values()) | ||||
| 		{ | ||||
| 			result.add(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel())); | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -597,7 +619,12 @@ public class SkillTreeData implements IXmlReader | ||||
| 	 */ | ||||
| 	public List<Skill> getGMAuraSkillTree() | ||||
| 	{ | ||||
| 		return _gameMasterAuraSkillTree.values().stream().map(entry -> SkillData.getInstance().getSkill(entry.getSkillId(), entry.getSkillLevel())).collect(Collectors.toList()); | ||||
| 		final List<Skill> result = new ArrayList<>(); | ||||
| 		for (SkillLearn skill : _gameMasterAuraSkillTree.values()) | ||||
| 		{ | ||||
| 			result.add(SkillData.getInstance().getSkill(skill.getSkillId(), skill.getSkillLevel())); | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -153,7 +153,15 @@ public class SpawnData implements IXmlReader | ||||
| 	 | ||||
| 	public List<SpawnTemplate> getSpawns(Predicate<SpawnTemplate> condition) | ||||
| 	{ | ||||
| 		return _spawns.stream().filter(condition).collect(Collectors.toList()); | ||||
| 		final List<SpawnTemplate> result = new ArrayList<>(); | ||||
| 		for (SpawnTemplate spawnTemplate : _spawns) | ||||
| 		{ | ||||
| 			if (condition.test(spawnTemplate)) | ||||
| 			{ | ||||
| 				result.add(spawnTemplate); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<SpawnGroup> getGroupsByName(String groupName) | ||||
|   | ||||
| @@ -26,6 +26,7 @@ import java.util.Calendar; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.HashMap; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| @@ -762,7 +763,15 @@ public class CastleManorManager implements IXmlReader, IStorable | ||||
| 	 | ||||
| 	public Set<Seed> getSeedsForCastle(int castleId) | ||||
| 	{ | ||||
| 		return _seeds.values().stream().filter(s -> s.getCastleId() == castleId).collect(Collectors.toSet()); | ||||
| 		Set<Seed> result = new HashSet<>(); | ||||
| 		for (Seed seed : _seeds.values()) | ||||
| 		{ | ||||
| 			if (seed.getCastleId() == castleId) | ||||
| 			{ | ||||
| 				result.add(seed); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public Set<Integer> getSeedIds() | ||||
|   | ||||
| @@ -20,12 +20,13 @@ import java.sql.Connection; | ||||
| import java.sql.PreparedStatement; | ||||
| import java.sql.ResultSet; | ||||
| import java.sql.Statement; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.Collections; | ||||
| import java.util.Comparator; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.OptionalInt; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.ScheduledFuture; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| @@ -213,9 +214,16 @@ public class ClanEntryManager | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public OptionalInt getClanIdForPlayerApplication(int playerId) | ||||
| 	public Integer getClanIdForPlayerApplication(int playerId) | ||||
| 	{ | ||||
| 		return _applicantList.entrySet().stream().filter(e -> e.getValue().containsKey(playerId)).mapToInt(e -> e.getKey()).findFirst(); | ||||
| 		for (Entry<Integer, Map<Integer, PledgeApplicantInfo>> entry : _applicantList.entrySet()) | ||||
| 		{ | ||||
| 			if (entry.getValue().containsKey(playerId)) | ||||
| 			{ | ||||
| 				return entry.getKey(); | ||||
| 			} | ||||
| 		} | ||||
| 		return 0; | ||||
| 	} | ||||
| 	 | ||||
| 	public boolean addToWaitingList(int playerId, PledgeWaitingInfo info) | ||||
| @@ -345,12 +353,41 @@ public class ClanEntryManager | ||||
| 	 | ||||
| 	public List<PledgeWaitingInfo> queryWaitingListByName(String name) | ||||
| 	{ | ||||
| 		return _waitingList.values().stream().filter(p -> p.getPlayerName().toLowerCase().contains(name)).collect(Collectors.toList()); | ||||
| 		final List<PledgeWaitingInfo> result = new ArrayList<>(); | ||||
| 		for (PledgeWaitingInfo p : _waitingList.values()) | ||||
| 		{ | ||||
| 			if (p.getPlayerName().toLowerCase().contains(name)) | ||||
| 			{ | ||||
| 				result.add(p); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<PledgeRecruitInfo> getSortedClanListByName(String query, int type) | ||||
| 	{ | ||||
| 		return type == 1 ? _clanList.values().stream().filter(p -> p.getClanName().toLowerCase().contains(query)).collect(Collectors.toList()) : _clanList.values().stream().filter(p -> p.getClanLeaderName().toLowerCase().contains(query)).collect(Collectors.toList()); | ||||
| 		final List<PledgeRecruitInfo> result = new ArrayList<>(); | ||||
| 		if (type == 1) | ||||
| 		{ | ||||
| 			for (PledgeRecruitInfo p : _clanList.values()) | ||||
| 			{ | ||||
| 				if (p.getClanName().toLowerCase().contains(query)) | ||||
| 				{ | ||||
| 					result.add(p); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			for (PledgeRecruitInfo p : _clanList.values()) | ||||
| 			{ | ||||
| 				if (p.getClanLeaderName().toLowerCase().contains(query)) | ||||
| 				{ | ||||
| 					result.add(p); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public PledgeRecruitInfo getClanById(int clanId) | ||||
|   | ||||
| @@ -18,6 +18,7 @@ package org.l2jmobius.gameserver.instancemanager; | ||||
|  | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.logging.Logger; | ||||
|  | ||||
| import org.l2jmobius.gameserver.data.xml.impl.ClanHallData; | ||||
| @@ -72,21 +73,26 @@ public class ClanHallAuctionManager extends AbstractEventManager<AbstractEvent<? | ||||
| 	 | ||||
| 	public ClanHallAuction getClanHallAuctionByClan(Clan clan) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return AUCTIONS.values().stream() | ||||
| 			.filter(a -> a.getBids().containsKey(clan.getId())) | ||||
| 			.findFirst() | ||||
| 			.orElse(null); | ||||
| 		//@formatter:on | ||||
| 		for (ClanHallAuction auction : AUCTIONS.values()) | ||||
| 		{ | ||||
| 			if (auction.getBids().containsKey(clan.getId())) | ||||
| 			{ | ||||
| 				return auction; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public boolean checkForClanBid(int clanHallId, Clan clan) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return AUCTIONS.entrySet().stream() | ||||
| 			.filter(a -> a.getKey() != clanHallId) | ||||
| 			.anyMatch(a -> a.getValue().getBids().containsKey(clan.getId())); | ||||
| 		//@formatter:on | ||||
| 		for (Entry<Integer, ClanHallAuction> auction : AUCTIONS.entrySet()) | ||||
| 		{ | ||||
| 			if ((auction.getKey() != clanHallId) && auction.getValue().getBids().containsKey(clan.getId())) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public static ClanHallAuctionManager getInstance() | ||||
|   | ||||
| @@ -442,7 +442,14 @@ public class CommissionManager | ||||
| 	 */ | ||||
| 	public boolean hasCommissionItems(int objectId) | ||||
| 	{ | ||||
| 		return _commissionItems.values().stream().anyMatch(item -> item.getItemInstance().getObjectId() == objectId); | ||||
| 		for (CommissionItem item : _commissionItems.values()) | ||||
| 		{ | ||||
| 			if (item.getItemInstance().getObjectId() == objectId) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -452,7 +459,14 @@ public class CommissionManager | ||||
| 	 */ | ||||
| 	public boolean hasCommissionedItemId(PlayerInstance player, int itemId) | ||||
| 	{ | ||||
| 		return !_commissionItems.values().stream().filter(c -> (c.getItemInstance().getOwnerId() == player.getObjectId()) && (c.getItemInstance().getItem().getId() == itemId)).collect(Collectors.toList()).isEmpty(); | ||||
| 		for (CommissionItem item : _commissionItems.values()) | ||||
| 		{ | ||||
| 			if ((item.getItemInstance().getOwnerId() == player.getObjectId()) && (item.getItemInstance().getItem().getId() == itemId)) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -434,7 +434,24 @@ public class InstanceManager implements IXmlReader | ||||
| 	 */ | ||||
| 	public Instance getPlayerInstance(PlayerInstance player, boolean isInside) | ||||
| 	{ | ||||
| 		return _instanceWorlds.values().stream().filter(i -> (isInside) ? i.containsPlayer(player) : i.isAllowed(player)).findFirst().orElse(null); | ||||
| 		for (Instance instance : _instanceWorlds.values()) | ||||
| 		{ | ||||
| 			if (isInside) | ||||
| 			{ | ||||
| 				if (instance.containsPlayer(player)) | ||||
| 				{ | ||||
| 					return instance; | ||||
| 				} | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				if (instance.isAllowed(player)) | ||||
| 				{ | ||||
| 					return instance; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -656,7 +673,15 @@ public class InstanceManager implements IXmlReader | ||||
| 	 */ | ||||
| 	public long getWorldCount(int templateId) | ||||
| 	{ | ||||
| 		return _instanceWorlds.values().stream().filter(i -> i.getTemplateId() == templateId).count(); | ||||
| 		long count = 0; | ||||
| 		for (Instance i : _instanceWorlds.values()) | ||||
| 		{ | ||||
| 			if (i.getTemplateId() == templateId) | ||||
| 			{ | ||||
| 				count++; | ||||
| 			} | ||||
| 		} | ||||
| 		return count; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -140,7 +140,15 @@ public class MailManager | ||||
| 	 | ||||
| 	public long getUnreadCount(PlayerInstance player) | ||||
| 	{ | ||||
| 		return getInbox(player.getObjectId()).stream().filter(Message::isUnread).count(); | ||||
| 		long count = 0; | ||||
| 		for (Message message : getInbox(player.getObjectId())) | ||||
| 		{ | ||||
| 			if (message.isUnread()) | ||||
| 			{ | ||||
| 				count++; | ||||
| 			} | ||||
| 		} | ||||
| 		return count; | ||||
| 	} | ||||
| 	 | ||||
| 	public int getMailsInProgress(int objectId) | ||||
|   | ||||
| @@ -16,6 +16,7 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.instancemanager; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| @@ -103,12 +104,19 @@ public class MatchingRoomManager | ||||
| 	 | ||||
| 	public List<MatchingRoom> getPartyMathchingRooms(int location, PartyMatchingRoomLevelType type, int requestorLevel) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return _rooms.getOrDefault(MatchingRoomType.PARTY, Collections.emptyMap()).values().stream() | ||||
| 				.filter(room -> (location < 0) || (room.getLocation() == location)) | ||||
| 				.filter(room -> (type == PartyMatchingRoomLevelType.ALL) || ((room.getMinLvl() >= requestorLevel) && (room.getMaxLvl() <= requestorLevel))) | ||||
| 				.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		final List<MatchingRoom> result = new ArrayList<>(); | ||||
| 		if (_rooms.containsKey(MatchingRoomType.PARTY)) | ||||
| 		{ | ||||
| 			for (MatchingRoom room : _rooms.get(MatchingRoomType.PARTY).values()) | ||||
| 			{ | ||||
| 				if (((location < 0) || (room.getLocation() == location)) // | ||||
| 					&& ((type == PartyMatchingRoomLevelType.ALL) || ((room.getMinLvl() >= requestorLevel) && (room.getMaxLvl() <= requestorLevel)))) | ||||
| 				{ | ||||
| 					result.add(room); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public Map<Integer, MatchingRoom> getCCMathchingRooms() | ||||
| @@ -118,12 +126,19 @@ public class MatchingRoomManager | ||||
| 	 | ||||
| 	public List<MatchingRoom> getCCMathchingRooms(int location, int level) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return _rooms.getOrDefault(MatchingRoomType.COMMAND_CHANNEL, Collections.emptyMap()).values().stream() | ||||
| 				.filter(r -> r.getLocation() == location) | ||||
| 				.filter(r -> (r.getMinLvl() <= level) && (r.getMaxLvl() >= level)) | ||||
| 				.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		final List<MatchingRoom> result = new ArrayList<>(); | ||||
| 		if (_rooms.containsKey(MatchingRoomType.COMMAND_CHANNEL)) | ||||
| 		{ | ||||
| 			for (MatchingRoom room : _rooms.get(MatchingRoomType.COMMAND_CHANNEL).values()) | ||||
| 			{ | ||||
| 				if ((room.getLocation() == location) // | ||||
| 					&& ((room.getMinLvl() <= level) && (room.getMaxLvl() >= level))) | ||||
| 				{ | ||||
| 					result.add(room); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public MatchingRoom getCCMatchingRoom(int roomId) | ||||
| @@ -133,13 +148,18 @@ public class MatchingRoomManager | ||||
| 	 | ||||
| 	public MatchingRoom getPartyMathchingRoom(int location, int level) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return _rooms.getOrDefault(MatchingRoomType.PARTY, Collections.emptyMap()).values().stream() | ||||
| 				.filter(r -> r.getLocation() == location) | ||||
| 				.filter(r -> (r.getMinLvl() <= level) && (r.getMaxLvl() >= level)) | ||||
| 				.findFirst() | ||||
| 				.orElse(null); | ||||
| 		//@formatter:on | ||||
| 		if (_rooms.containsKey(MatchingRoomType.PARTY)) | ||||
| 		{ | ||||
| 			for (MatchingRoom room : _rooms.get(MatchingRoomType.PARTY).values()) | ||||
| 			{ | ||||
| 				if ((room.getLocation() == location) // | ||||
| 					&& ((room.getMinLvl() <= level) && (room.getMaxLvl() >= level))) | ||||
| 				{ | ||||
| 					return room; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public MatchingRoom getPartyMathchingRoom(int roomId) | ||||
|   | ||||
| @@ -24,7 +24,6 @@ import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.Map; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.Objects; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| @@ -34,7 +33,6 @@ import org.l2jmobius.gameserver.model.Mentee; | ||||
| import org.l2jmobius.gameserver.model.World; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.model.skills.BuffInfo; | ||||
| import org.l2jmobius.gameserver.model.skills.Skill; | ||||
| import org.l2jmobius.gameserver.model.variables.PlayerVariables; | ||||
|  | ||||
| /** | ||||
| @@ -134,13 +132,13 @@ public class MentorManager | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		//@formatter:off | ||||
| 		player.getEffectList().getEffects() | ||||
| 			.stream() | ||||
| 			.map(BuffInfo::getSkill) | ||||
| 			.filter(Skill::isMentoring) | ||||
| 			.forEach(player::stopSkillEffects); | ||||
| 		//@formatter:on | ||||
| 		for (BuffInfo info : player.getEffectList().getEffects()) | ||||
| 		{ | ||||
| 			if (info.getSkill().isMentoring()) | ||||
| 			{ | ||||
| 				player.stopSkillEffects(info.getSkill()); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void setPenalty(int mentorId, long penalty) | ||||
| @@ -250,7 +248,14 @@ public class MentorManager | ||||
| 	 | ||||
| 	public boolean hasOnlineMentees(int menteorId) | ||||
| 	{ | ||||
| 		return getMentees(menteorId).stream().filter(Objects::nonNull).filter(Mentee::isOnline).count() > 0; | ||||
| 		for (Mentee mentee : getMentees(menteorId)) | ||||
| 		{ | ||||
| 			if ((mentee != null) && mentee.isOnline()) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public static MentorManager getInstance() | ||||
|   | ||||
| @@ -177,14 +177,17 @@ public class PremiumManager | ||||
| 		premiumData.put(accountName, newPremiumExpiration); | ||||
| 		 | ||||
| 		// UPDATE PlAYER PREMIUMSTATUS | ||||
| 		final PlayerInstance playerOnline = World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null); | ||||
| 		if (playerOnline != null) | ||||
| 		for (PlayerInstance player : World.getInstance().getPlayers()) | ||||
| 		{ | ||||
| 			stopExpireTask(playerOnline); | ||||
| 			startExpireTask(playerOnline, newPremiumExpiration - now); | ||||
| 			if (!playerOnline.hasPremiumStatus()) | ||||
| 			if (accountName.equals(player.getAccountName())) | ||||
| 			{ | ||||
| 				playerOnline.setPremiumStatus(true); | ||||
| 				stopExpireTask(player); | ||||
| 				startExpireTask(player, newPremiumExpiration - now); | ||||
| 				if (!player.hasPremiumStatus()) | ||||
| 				{ | ||||
| 					player.setPremiumStatus(true); | ||||
| 				} | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -193,11 +196,14 @@ public class PremiumManager | ||||
| 	{ | ||||
| 		if (checkOnline) | ||||
| 		{ | ||||
| 			final PlayerInstance playerOnline = World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null); | ||||
| 			if ((playerOnline != null) && playerOnline.hasPremiumStatus()) | ||||
| 			for (PlayerInstance player : World.getInstance().getPlayers()) | ||||
| 			{ | ||||
| 				playerOnline.setPremiumStatus(false); | ||||
| 				stopExpireTask(playerOnline); | ||||
| 				if (accountName.equals(player.getAccountName()) && player.hasPremiumStatus()) | ||||
| 				{ | ||||
| 					player.setPremiumStatus(false); | ||||
| 					stopExpireTask(player); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
|   | ||||
| @@ -379,7 +379,14 @@ public class SellBuffsManager implements IXmlReader | ||||
| 	 | ||||
| 	public boolean isInSellList(PlayerInstance player, Skill skill) | ||||
| 	{ | ||||
| 		return player.getSellingBuffs().stream().filter(h -> (h.getSkillId() == skill.getId())).findFirst().orElse(null) != null; | ||||
| 		for (SellBuffHolder holder : player.getSellingBuffs()) | ||||
| 		{ | ||||
| 			if (holder.getSkillId() == skill.getId()) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public boolean canStartSellBuffs(PlayerInstance player) | ||||
|   | ||||
| @@ -99,7 +99,14 @@ public class SiegeGuardManager | ||||
| 	 */ | ||||
| 	public SiegeGuardHolder getSiegeGuardByItem(int castleId, int itemId) | ||||
| 	{ | ||||
| 		return CastleData.getInstance().getSiegeGuardsForCastle(castleId).stream().filter(g -> (g.getItemId() == itemId)).findFirst().orElse(null); | ||||
| 		for (SiegeGuardHolder holder : CastleData.getInstance().getSiegeGuardsForCastle(castleId)) | ||||
| 		{ | ||||
| 			if (holder.getItemId() == itemId) | ||||
| 			{ | ||||
| 				return holder; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -110,7 +117,14 @@ public class SiegeGuardManager | ||||
| 	 */ | ||||
| 	public SiegeGuardHolder getSiegeGuardByNpc(int castleId, int npcId) | ||||
| 	{ | ||||
| 		return CastleData.getInstance().getSiegeGuardsForCastle(castleId).stream().filter(g -> (g.getNpcId() == npcId)).findFirst().orElse(null); | ||||
| 		for (SiegeGuardHolder holder : CastleData.getInstance().getSiegeGuardsForCastle(castleId)) | ||||
| 		{ | ||||
| 			if (holder.getNpcId() == npcId) | ||||
| 			{ | ||||
| 				return holder; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -120,7 +134,14 @@ public class SiegeGuardManager | ||||
| 	 */ | ||||
| 	public boolean isTooCloseToAnotherTicket(PlayerInstance player) | ||||
| 	{ | ||||
| 		return _droppedTickets.stream().filter(g -> g.calculateDistance3D(player) < 25).findFirst().orElse(null) != null; | ||||
| 		for (ItemInstance ticket : _droppedTickets) | ||||
| 		{ | ||||
| 			if (ticket.calculateDistance3D(player) < 25) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -131,8 +152,15 @@ public class SiegeGuardManager | ||||
| 	 */ | ||||
| 	public boolean isAtNpcLimit(int castleId, int itemId) | ||||
| 	{ | ||||
| 		final long count = _droppedTickets.stream().filter(i -> i.getId() == itemId).count(); | ||||
| 		final SiegeGuardHolder holder = getSiegeGuardByItem(castleId, itemId); | ||||
| 		long count = 0; | ||||
| 		for (ItemInstance ticket : _droppedTickets) | ||||
| 		{ | ||||
| 			if (ticket.getId() == itemId) | ||||
| 			{ | ||||
| 				count++; | ||||
| 			} | ||||
| 		} | ||||
| 		return count >= holder.getMaxNpcAmout(); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -24,7 +24,6 @@ import java.util.HashMap; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Optional; | ||||
| import java.util.OptionalInt; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||
| @@ -557,10 +556,12 @@ public class ZoneManager implements IXmlReader | ||||
| 	{ | ||||
| 		for (Map<Integer, ? extends ZoneType> map : _classZones.values()) | ||||
| 		{ | ||||
| 			final Optional<? extends ZoneType> zoneType = map.values().stream().filter(z -> (z.getName() != null) && z.getName().equals(name)).findAny(); | ||||
| 			if (zoneType.isPresent()) | ||||
| 			for (ZoneType zone : map.values()) | ||||
| 			{ | ||||
| 				return zoneType.get(); | ||||
| 				if ((zone.getName() != null) && zone.getName().equals(name)) | ||||
| 				{ | ||||
| 					return zone; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| @@ -589,10 +590,15 @@ public class ZoneManager implements IXmlReader | ||||
| 	@SuppressWarnings("unchecked") | ||||
| 	public <T extends ZoneType> T getZoneByName(String name, Class<T> zoneType) | ||||
| 	{ | ||||
| 		final Optional<? extends ZoneType> zone = _classZones.get(zoneType).values().stream().filter(z -> (z.getName() != null) && z.getName().equals(name)).findAny(); | ||||
| 		if (zone.isPresent()) | ||||
| 		if (_classZones.containsKey(zoneType)) | ||||
| 		{ | ||||
| 			return (T) zone.get(); | ||||
| 			for (ZoneType zone : _classZones.get(zoneType).values()) | ||||
| 			{ | ||||
| 				if ((zone.getName() != null) && zone.getName().equals(name)) | ||||
| 				{ | ||||
| 					return (T) zone; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
|   | ||||
| @@ -16,12 +16,12 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.model; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.EnumSet; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Optional; | ||||
| import java.util.Queue; | ||||
| import java.util.Set; | ||||
| @@ -30,8 +30,6 @@ import java.util.concurrent.ConcurrentLinkedQueue; | ||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||
| import java.util.function.Predicate; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| @@ -137,7 +135,15 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public List<BuffInfo> getBuffs() | ||||
| 	{ | ||||
| 		return _actives.stream().filter(b -> b.getSkill().getBuffType().isBuff()).collect(Collectors.toList()); | ||||
| 		final List<BuffInfo> result = new ArrayList<>(); | ||||
| 		for (BuffInfo info : _actives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getBuffType().isBuff()) | ||||
| 			{ | ||||
| 				result.add(info); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -146,7 +152,15 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public List<BuffInfo> getDances() | ||||
| 	{ | ||||
| 		return _actives.stream().filter(b -> b.getSkill().getBuffType().isDance()).collect(Collectors.toList()); | ||||
| 		final List<BuffInfo> result = new ArrayList<>(); | ||||
| 		for (BuffInfo info : _actives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getBuffType().isDance()) | ||||
| 			{ | ||||
| 				result.add(info); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -155,7 +169,15 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public List<BuffInfo> getDebuffs() | ||||
| 	{ | ||||
| 		return _actives.stream().filter(b -> b.getSkill().isDebuff()).collect(Collectors.toList()); | ||||
| 		final List<BuffInfo> result = new ArrayList<>(); | ||||
| 		for (BuffInfo info : _actives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getBuffType().isDebuff()) | ||||
| 			{ | ||||
| 				result.add(info); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -165,7 +187,21 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public boolean isAffectedBySkill(int skillId) | ||||
| 	{ | ||||
| 		return (_actives.stream().anyMatch(i -> i.getSkill().getId() == skillId)) || (_passives.stream().anyMatch(i -> i.getSkill().getId() == skillId)); | ||||
| 		for (BuffInfo info : _actives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getId() == skillId) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		for (BuffInfo info : _passives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getId() == skillId) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -175,7 +211,21 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public BuffInfo getBuffInfoBySkillId(int skillId) | ||||
| 	{ | ||||
| 		return Stream.concat(_actives.stream(), _passives.stream()).filter(b -> b.getSkill().getId() == skillId).findFirst().orElse(null); | ||||
| 		for (BuffInfo info : _actives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getId() == skillId) | ||||
| 			{ | ||||
| 				return info; | ||||
| 			} | ||||
| 		} | ||||
| 		for (BuffInfo info : _passives) | ||||
| 		{ | ||||
| 			if (info.getSkill().getId() == skillId) | ||||
| 			{ | ||||
| 				return info; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -195,7 +245,14 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public boolean hasAbnormalType(Collection<AbnormalType> types) | ||||
| 	{ | ||||
| 		return _stackedEffects.stream().anyMatch(types::contains); | ||||
| 		for (AbnormalType abnormalType : _stackedEffects) | ||||
| 		{ | ||||
| 			if (types.contains(abnormalType)) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -205,7 +262,17 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public boolean hasAbnormalType(AbnormalType type, Predicate<BuffInfo> filter) | ||||
| 	{ | ||||
| 		return hasAbnormalType(type) && _actives.stream().filter(i -> i.isAbnormalType(type)).anyMatch(filter); | ||||
| 		if (hasAbnormalType(type)) | ||||
| 		{ | ||||
| 			for (BuffInfo info : _actives) | ||||
| 			{ | ||||
| 				if (info.isAbnormalType(type) && filter.test(info)) | ||||
| 				{ | ||||
| 					return true; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -216,7 +283,17 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public BuffInfo getFirstBuffInfoByAbnormalType(AbnormalType type) | ||||
| 	{ | ||||
| 		return hasAbnormalType(type) ? _actives.stream().filter(i -> i.isAbnormalType(type)).findFirst().orElse(null) : null; | ||||
| 		if (hasAbnormalType(type)) | ||||
| 		{ | ||||
| 			for (BuffInfo info : _actives) | ||||
| 			{ | ||||
| 				if (info.isAbnormalType(type)) | ||||
| 				{ | ||||
| 					return info; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -353,9 +430,18 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public void stopAllEffectsWithoutExclusions(boolean update, boolean broadcast) | ||||
| 	{ | ||||
| 		_actives.stream().forEach(this::remove); | ||||
| 		_passives.stream().forEach(this::remove); | ||||
| 		_options.stream().forEach(this::remove); | ||||
| 		for (BuffInfo info : _actives) | ||||
| 		{ | ||||
| 			remove(info); | ||||
| 		} | ||||
| 		for (BuffInfo info : _passives) | ||||
| 		{ | ||||
| 			remove(info); | ||||
| 		} | ||||
| 		for (BuffInfo info : _options) | ||||
| 		{ | ||||
| 			remove(info); | ||||
| 		} | ||||
| 		 | ||||
| 		// Update stats, effect flags and icons. | ||||
| 		if (update) | ||||
| @@ -426,9 +512,26 @@ public class EffectList | ||||
| 	 */ | ||||
| 	public void stopEffects(EffectFlag effectFlag) | ||||
| 	{ | ||||
| 		if (isAffected(effectFlag)) | ||||
| 		if (isAffected(effectFlag) && !_actives.isEmpty()) | ||||
| 		{ | ||||
| 			stopEffects(info -> info.getEffects().stream().anyMatch(effect -> (effect != null) && ((effect.getEffectFlags() & effectFlag.getMask()) != 0)), true, true); | ||||
| 			boolean update = false; | ||||
| 			for (BuffInfo info : _actives) | ||||
| 			{ | ||||
| 				for (AbstractEffect effect : info.getEffects()) | ||||
| 				{ | ||||
| 					if ((effect != null) && ((effect.getEffectFlags() & effectFlag.getMask()) != 0)) | ||||
| 					{ | ||||
| 						remove(info); | ||||
| 						update = true; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// Update stats, effect flags and icons. | ||||
| 			if (update) | ||||
| 			{ | ||||
| 				updateEffectList(true); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| @@ -507,7 +610,13 @@ public class EffectList | ||||
| 	{ | ||||
| 		if (!_actives.isEmpty()) | ||||
| 		{ | ||||
| 			_actives.stream().filter(filter).forEach(this::remove); | ||||
| 			for (BuffInfo info : _actives) | ||||
| 			{ | ||||
| 				if (filter.test(info)) | ||||
| 				{ | ||||
| 					remove(info); | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// Update stats, effect flags and icons. | ||||
| 			if (update) | ||||
| @@ -923,11 +1032,14 @@ public class EffectList | ||||
| 		} | ||||
| 		 | ||||
| 		// Remove previous passives of this id. | ||||
| 		_passives.stream().filter(Objects::nonNull).filter(b -> b.getSkill().getId() == skill.getId()).forEach(b -> | ||||
| 		for (BuffInfo b : _passives) | ||||
| 		{ | ||||
| 			b.setInUse(false); | ||||
| 			_passives.remove(b); | ||||
| 		}); | ||||
| 			if ((b != null) && (b.getSkill().getId() == skill.getId())) | ||||
| 			{ | ||||
| 				b.setInUse(false); | ||||
| 				_passives.remove(b); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		_passives.add(info); | ||||
| 		 | ||||
| @@ -940,11 +1052,14 @@ public class EffectList | ||||
| 		if (info.getOption() != null) | ||||
| 		{ | ||||
| 			// Remove previous options of this id. | ||||
| 			_options.stream().filter(Objects::nonNull).filter(b -> b.getOption().getId() == info.getOption().getId()).forEach(b -> | ||||
| 			for (BuffInfo b : _options) | ||||
| 			{ | ||||
| 				b.setInUse(false); | ||||
| 				_options.remove(b); | ||||
| 			}); | ||||
| 				if ((b != null) && (b.getOption().getId() == info.getOption().getId())) | ||||
| 				{ | ||||
| 					b.setInUse(false); | ||||
| 					_options.remove(b); | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			_options.add(info); | ||||
| 			 | ||||
| @@ -969,11 +1084,9 @@ public class EffectList | ||||
| 			final Optional<ExOlympiadSpelledInfo> os = (player.isInOlympiadMode() && player.isOlympiadStart()) ? Optional.of(new ExOlympiadSpelledInfo(player)) : Optional.empty(); | ||||
| 			if (!_actives.isEmpty()) | ||||
| 			{ | ||||
| 				//@formatter:off | ||||
| 				_actives.stream() | ||||
| 					.filter(Objects::nonNull) | ||||
| 					.filter(BuffInfo::isInUse) | ||||
| 					.forEach(info -> | ||||
| 				for (BuffInfo info : _actives) | ||||
| 				{ | ||||
| 					if ((info != null) && info.isInUse()) | ||||
| 					{ | ||||
| 						if (info.getSkill().isHealingPotionSkill()) | ||||
| 						{ | ||||
| @@ -985,8 +1098,8 @@ public class EffectList | ||||
| 							ps.filter(p -> !info.getSkill().isToggle()).ifPresent(p -> p.addSkill(info)); | ||||
| 							os.ifPresent(o -> o.addSkill(info)); | ||||
| 						} | ||||
| 					}); | ||||
| 				//@formatter:on | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// Send icon update for player buff bar. | ||||
| @@ -1015,14 +1128,13 @@ public class EffectList | ||||
| 		 | ||||
| 		// Update effect icons for everyone targeting this owner. | ||||
| 		final ExAbnormalStatusUpdateFromTarget upd = new ExAbnormalStatusUpdateFromTarget(_owner); | ||||
| 		 | ||||
| 		// @formatter:off | ||||
| 		_owner.getStatus().getStatusListener().stream() | ||||
| 			.filter(Objects::nonNull) | ||||
| 			.filter(WorldObject::isPlayer) | ||||
| 			.map(Creature::getActingPlayer) | ||||
| 			.forEach(upd::sendTo); | ||||
| 		// @formatter:on | ||||
| 		for (Creature creature : _owner.getStatus().getStatusListener()) | ||||
| 		{ | ||||
| 			if ((creature != null) && creature.isPlayer()) | ||||
| 			{ | ||||
| 				upd.sendTo(creature.getActingPlayer()); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (_owner.isPlayer() && (_owner.getTarget() == _owner)) | ||||
| 		{ | ||||
|   | ||||
| @@ -333,7 +333,13 @@ public class Party extends AbstractPlayerGroup | ||||
| 		msg.addString(player.getName()); | ||||
| 		broadcastPacket(msg); | ||||
| 		 | ||||
| 		_members.stream().filter(member -> member != player).forEach(member -> member.sendPacket(new PartySmallWindowAdd(player, this))); | ||||
| 		for (PlayerInstance member : _members) | ||||
| 		{ | ||||
| 			if (member != player) | ||||
| 			{ | ||||
| 				member.sendPacket(new PartySmallWindowAdd(player, this)); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// send the position of all party members to the new party member | ||||
| 		// player.sendPacket(new PartyMemberPosition(this)); | ||||
| @@ -856,10 +862,13 @@ public class Party extends AbstractPlayerGroup | ||||
| 				// The servitor penalty | ||||
| 				float penalty = 1; | ||||
| 				 | ||||
| 				final Summon summon = member.getServitors().values().stream().filter(s -> ((ServitorInstance) s).getExpMultiplier() > 1).findFirst().orElse(null); | ||||
| 				if (summon != null) | ||||
| 				for (Summon summon : member.getServitors().values()) | ||||
| 				{ | ||||
| 					penalty = ((ServitorInstance) summon).getExpMultiplier(); | ||||
| 					if (((ServitorInstance) summon).getExpMultiplier() > 1) | ||||
| 					{ | ||||
| 						penalty = ((ServitorInstance) summon).getExpMultiplier(); | ||||
| 						break; | ||||
| 					} | ||||
| 				} | ||||
| 				 | ||||
| 				final double sqLevel = member.getLevel() * member.getLevel(); | ||||
|   | ||||
| @@ -22,11 +22,9 @@ import java.util.Collection; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Optional; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.atomic.AtomicReference; | ||||
| import java.util.logging.Level; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.concurrent.ThreadPool; | ||||
| @@ -390,11 +388,27 @@ public class Attackable extends Npc | ||||
| 				if (party != null) | ||||
| 				{ | ||||
| 					final CommandChannel command = party.getCommandChannel(); | ||||
| 					//@formatter:off | ||||
| 					final List<PlayerInstance> members = command != null ?  | ||||
| 						command.getMembers().stream().filter(p -> p.calculateDistance3D(this) < Config.ALT_PARTY_RANGE).collect(Collectors.toList()) : | ||||
| 						player.getParty().getMembers().stream().filter(p -> p.calculateDistance3D(this) < Config.ALT_PARTY_RANGE).collect(Collectors.toList()); | ||||
| 					//@formatter:on | ||||
| 					final List<PlayerInstance> members = new ArrayList<>(); | ||||
| 					if (command != null) | ||||
| 					{ | ||||
| 						for (PlayerInstance p : command.getMembers()) | ||||
| 						{ | ||||
| 							if (p.calculateDistance3D(this) < Config.ALT_PARTY_RANGE) | ||||
| 							{ | ||||
| 								members.add(p); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					else | ||||
| 					{ | ||||
| 						for (PlayerInstance p : player.getParty().getMembers()) | ||||
| 						{ | ||||
| 							if (p.calculateDistance3D(this) < Config.ALT_PARTY_RANGE) | ||||
| 							{ | ||||
| 								members.add(p); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 					 | ||||
| 					members.forEach(p -> | ||||
| 					{ | ||||
| @@ -452,10 +466,13 @@ public class Attackable extends Npc | ||||
| 					// If this attacker have servitor, get Exp Penalty applied for the servitor. | ||||
| 					float penalty = 1; | ||||
| 					 | ||||
| 					final Optional<Summon> summon = attacker.getServitors().values().stream().filter(s -> ((ServitorInstance) s).getExpMultiplier() > 1).findFirst(); | ||||
| 					if (summon.isPresent()) | ||||
| 					for (Summon summon : attacker.getServitors().values()) | ||||
| 					{ | ||||
| 						penalty = ((ServitorInstance) summon.get()).getExpMultiplier(); | ||||
| 						if (((ServitorInstance) summon).getExpMultiplier() > 1) | ||||
| 						{ | ||||
| 							penalty = ((ServitorInstance) summon).getExpMultiplier(); | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 					 | ||||
| 					// If there's NO party in progress | ||||
|   | ||||
| @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.actor; | ||||
| import static org.l2jmobius.gameserver.ai.CtrlIntention.AI_INTENTION_ACTIVE; | ||||
|  | ||||
| import java.lang.ref.WeakReference; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.EnumSet; | ||||
| @@ -37,7 +38,6 @@ import java.util.concurrent.atomic.AtomicInteger; | ||||
| import java.util.concurrent.locks.StampedLock; | ||||
| import java.util.function.Predicate; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.concurrent.ThreadPool; | ||||
| @@ -5115,7 +5115,16 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe | ||||
| 		{ | ||||
| 			filter = filter.and(additionalFilter); | ||||
| 		} | ||||
| 		return _skillCasters.values().stream().filter(filter).collect(Collectors.toList()); | ||||
| 		 | ||||
| 		final List<SkillCaster> result = new ArrayList<>(); | ||||
| 		for (SkillCaster skillCaster : _skillCasters.values()) | ||||
| 		{ | ||||
| 			if (filter.test(skillCaster)) | ||||
| 			{ | ||||
| 				result.add(skillCaster); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	@SafeVarargs | ||||
| @@ -5126,7 +5135,15 @@ public abstract class Creature extends WorldObject implements ISkillsHolder, IDe | ||||
| 		{ | ||||
| 			filter = filter.and(additionalFilter); | ||||
| 		} | ||||
| 		return _skillCasters.values().stream().filter(filter).findAny().orElse(null); | ||||
| 		 | ||||
| 		for (SkillCaster skillCaster : _skillCasters.values()) | ||||
| 		{ | ||||
| 			if (filter.test(skillCaster)) | ||||
| 			{ | ||||
| 				return skillCaster; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -5383,7 +5383,14 @@ public class PlayerInstance extends Playable | ||||
| 	 */ | ||||
| 	public TrapInstance getTrap() | ||||
| 	{ | ||||
| 		return getSummonedNpcs().stream().filter(Npc::isTrap).map(TrapInstance.class::cast).findAny().orElse(null); | ||||
| 		for (Npc npc : getSummonedNpcs()) | ||||
| 		{ | ||||
| 			if (npc.isTrap()) | ||||
| 			{ | ||||
| 				return (TrapInstance) npc; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -9617,12 +9624,26 @@ public class PlayerInstance extends Playable | ||||
| 	 | ||||
| 	public boolean hasDualClass() | ||||
| 	{ | ||||
| 		return getSubClasses().values().stream().anyMatch(SubClass::isDualClass); | ||||
| 		for (SubClass subClass : _subClasses.values()) | ||||
| 		{ | ||||
| 			if (subClass.isDualClass()) | ||||
| 			{ | ||||
| 				return true; | ||||
| 			} | ||||
| 		} | ||||
| 		return false; | ||||
| 	} | ||||
| 	 | ||||
| 	public SubClass getDualClass() | ||||
| 	{ | ||||
| 		return getSubClasses().values().stream().filter(SubClass::isDualClass).findFirst().orElse(null); | ||||
| 		for (SubClass subClass : _subClasses.values()) | ||||
| 		{ | ||||
| 			if (subClass.isDualClass()) | ||||
| 			{ | ||||
| 				return subClass; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public Map<Integer, SubClass> getSubClasses() | ||||
| @@ -11493,7 +11514,13 @@ public class PlayerInstance extends Playable | ||||
| 		if (isTransformed() && !_transformSkills.isEmpty()) | ||||
| 		{ | ||||
| 			// Include transformation skills and those skills that are allowed during transformation. | ||||
| 			currentSkills = currentSkills.stream().filter(Skill::allowOnTransform).collect(Collectors.toList()); | ||||
| 			for (Skill skill : currentSkills) | ||||
| 			{ | ||||
| 				if (!skill.allowOnTransform()) | ||||
| 				{ | ||||
| 					currentSkills.remove(skill); | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// Revelation skills. | ||||
| 			if (isDualClassActive()) | ||||
| @@ -11526,14 +11553,18 @@ public class PlayerInstance extends Playable | ||||
| 			currentSkills.addAll(_transformSkills.values()); | ||||
| 		} | ||||
| 		 | ||||
| 		//@formatter:off | ||||
| 		return currentSkills.stream() | ||||
| 							.filter(Objects::nonNull) | ||||
| 							.filter(s -> !s.isBlockActionUseSkill()) // Skills that are blocked from player use are not shown in skill list. | ||||
| 							.filter(s -> !SkillTreeData.getInstance().isAlchemySkill(s.getId(), s.getLevel())) | ||||
| 							.filter(s -> s.isDisplayInList()) | ||||
| 							.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		for (Skill skill : currentSkills) | ||||
| 		{ | ||||
| 			if ((skill == null) // | ||||
| 				|| skill.isBlockActionUseSkill() // Skills that are blocked from player use are not shown in skill list. | ||||
| 				|| SkillTreeData.getInstance().isAlchemySkill(skill.getId(), skill.getLevel()) // | ||||
| 				|| !skill.isDisplayInList()) | ||||
| 			{ | ||||
| 				currentSkills.remove(skill); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		return currentSkills; | ||||
| 	} | ||||
| 	 | ||||
| 	protected void startFeed(int npcId) | ||||
| @@ -13587,9 +13618,17 @@ public class PlayerInstance extends Playable | ||||
| 	 * @param clazz | ||||
| 	 * @return the event instance or null in case events map is not initialized yet or event is not registered | ||||
| 	 */ | ||||
| 	@SuppressWarnings("unchecked") | ||||
| 	public <T extends AbstractEvent<?>> T getEvent(Class<T> clazz) | ||||
| 	{ | ||||
| 		return _events.values().stream().filter(event -> clazz.isAssignableFrom(event.getClass())).map(clazz::cast).findFirst().orElse(null); | ||||
| 		for (AbstractEvent<?> event : _events.values()) | ||||
| 		{ | ||||
| 			if (clazz.isAssignableFrom(event.getClass())) | ||||
| 			{ | ||||
| 				return (T) event; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -13597,7 +13636,11 @@ public class PlayerInstance extends Playable | ||||
| 	 */ | ||||
| 	public AbstractEvent<?> getEvent() | ||||
| 	{ | ||||
| 		return _events.values().stream().findFirst().orElse(null); | ||||
| 		for (AbstractEvent<?> event : _events.values()) | ||||
| 		{ | ||||
| 			return event; | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -437,8 +437,16 @@ public class SchemeBufferInstance extends Npc | ||||
| 		return (objectsSize / pageSize) + ((objectsSize % pageSize) == 0 ? 0 : 1); | ||||
| 	} | ||||
| 	 | ||||
| 	private static long getCountOf(List<Integer> skills, boolean dances) | ||||
| 	private static int getCountOf(List<Integer> skills, boolean dances) | ||||
| 	{ | ||||
| 		return skills.stream().filter(sId -> SkillData.getInstance().getSkill(sId, 1).isDance() == dances).count(); | ||||
| 		int count = 0; | ||||
| 		for (int skillId : skills) | ||||
| 		{ | ||||
| 			if (SkillData.getInstance().getSkill(skillId, 1).isDance() == dances) | ||||
| 			{ | ||||
| 				count++; | ||||
| 			} | ||||
| 		} | ||||
| 		return count; | ||||
| 	} | ||||
| } | ||||
| @@ -64,7 +64,14 @@ public class SayuneRequest extends AbstractRequest | ||||
| 		} | ||||
| 		else if (_isSelecting) | ||||
| 		{ | ||||
| 			return _possibleEntries.stream().filter(loc -> loc.getId() == pos).findAny().orElse(null); | ||||
| 			for (SayuneEntry entry : _possibleEntries) | ||||
| 			{ | ||||
| 				if (entry.getId() == pos) | ||||
| 				{ | ||||
| 					return entry; | ||||
| 				} | ||||
| 			} | ||||
| 			return null; | ||||
| 		} | ||||
| 		return _possibleEntries.removeFirst(); | ||||
| 	} | ||||
|   | ||||
| @@ -31,13 +31,12 @@ import java.util.concurrent.ConcurrentLinkedDeque; | ||||
| import java.util.concurrent.locks.ReentrantReadWriteLock; | ||||
| import java.util.function.BiFunction; | ||||
| import java.util.function.BiPredicate; | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.gameserver.enums.AttributeType; | ||||
| import org.l2jmobius.gameserver.enums.Position; | ||||
| import org.l2jmobius.gameserver.model.EffectList; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| import org.l2jmobius.gameserver.model.effects.AbstractEffect; | ||||
| import org.l2jmobius.gameserver.model.items.instance.ItemInstance; | ||||
| import org.l2jmobius.gameserver.model.skills.AbnormalType; | ||||
| import org.l2jmobius.gameserver.model.skills.BuffInfo; | ||||
| @@ -886,36 +885,80 @@ public class CreatureStat | ||||
| 			// Wipe all the data | ||||
| 			resetStats(); | ||||
| 			 | ||||
| 			// Collect all necessary effects | ||||
| 			final EffectList effectList = _creature.getEffectList(); | ||||
| 			final Stream<BuffInfo> passives = effectList.getPassives().stream().filter(BuffInfo::isInUse).filter(info -> info.getSkill().checkConditions(SkillConditionScope.PASSIVE, _creature, _creature)); | ||||
| 			final Stream<BuffInfo> options = effectList.getOptions().stream().filter(BuffInfo::isInUse); | ||||
| 			final Stream<BuffInfo> effectsStream = Stream.concat(effectList.getEffects().stream().filter(BuffInfo::isInUse), Stream.concat(passives, options)); | ||||
| 			 | ||||
| 			// Call pump to each effect | ||||
| 			//@formatter:off | ||||
| 			effectsStream.forEach(info -> info.getEffects().stream() | ||||
| 				.filter(effect -> effect.canStart(info.getEffector(), info.getEffected(), info.getSkill())) | ||||
| 				.filter(effect -> effect.canPump(info.getEffector(), info.getEffected(), info.getSkill())) | ||||
| 				.forEach(effect -> effect.pump(info.getEffected(), info.getSkill()))); | ||||
| 			//@formatter:on | ||||
| 			for (BuffInfo info : _creature.getEffectList().getPassives()) | ||||
| 			{ | ||||
| 				if (info.isInUse() && info.getSkill().checkConditions(SkillConditionScope.PASSIVE, _creature, _creature)) | ||||
| 				{ | ||||
| 					for (AbstractEffect effect : info.getEffects()) | ||||
| 					{ | ||||
| 						if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()) && effect.canPump(info.getEffector(), info.getEffected(), info.getSkill())) | ||||
| 						{ | ||||
| 							effect.pump(info.getEffected(), info.getSkill()); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			for (BuffInfo info : _creature.getEffectList().getOptions()) | ||||
| 			{ | ||||
| 				if (info.isInUse()) | ||||
| 				{ | ||||
| 					for (AbstractEffect effect : info.getEffects()) | ||||
| 					{ | ||||
| 						if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()) && effect.canPump(info.getEffector(), info.getEffected(), info.getSkill())) | ||||
| 						{ | ||||
| 							effect.pump(info.getEffected(), info.getSkill()); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			for (BuffInfo info : _creature.getEffectList().getEffects()) | ||||
| 			{ | ||||
| 				if (info.isInUse()) | ||||
| 				{ | ||||
| 					for (AbstractEffect effect : info.getEffects()) | ||||
| 					{ | ||||
| 						if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()) && effect.canPump(info.getEffector(), info.getEffected(), info.getSkill())) | ||||
| 						{ | ||||
| 							effect.pump(info.getEffected(), info.getSkill()); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// Pump for summon ABILITY_CHANGE abnormal type. | ||||
| 			if (_creature.isSummon() && (_creature.getActingPlayer() != null) && _creature.getActingPlayer().hasAbnormalType(AbnormalType.ABILITY_CHANGE)) | ||||
| 			{ | ||||
| 				//@formatter:off | ||||
| 				_creature.getActingPlayer().getEffectList().getEffects().stream() | ||||
| 					.filter(BuffInfo::isInUse) | ||||
| 					.filter(info -> info.isAbnormalType(AbnormalType.ABILITY_CHANGE)) | ||||
| 					.forEach(info -> info.getEffects().stream() | ||||
| 						.filter(effect -> effect.canStart(info.getEffector(), info.getEffected(), info.getSkill())) | ||||
| 						.filter(effect -> effect.canPump(_creature, _creature, info.getSkill())) | ||||
| 						.forEach(effect -> effect.pump(_creature, info.getSkill()))); | ||||
| 				//@formatter:on | ||||
| 				for (BuffInfo info : _creature.getActingPlayer().getEffectList().getEffects()) | ||||
| 				{ | ||||
| 					if (info.isInUse() && info.isAbnormalType(AbnormalType.ABILITY_CHANGE)) | ||||
| 					{ | ||||
| 						for (AbstractEffect effect : info.getEffects()) | ||||
| 						{ | ||||
| 							if (effect.canStart(info.getEffector(), info.getEffected(), info.getSkill()) && effect.canPump(_creature, _creature, info.getSkill())) | ||||
| 							{ | ||||
| 								effect.pump(_creature, info.getSkill()); | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			// Merge with additional stats | ||||
| 			_additionalAdd.stream().filter(holder -> holder.verifyCondition(_creature)).forEach(holder -> mergeAdd(holder.getStat(), holder.getValue())); | ||||
| 			_additionalMul.stream().filter(holder -> holder.verifyCondition(_creature)).forEach(holder -> mergeMul(holder.getStat(), holder.getValue())); | ||||
| 			for (StatHolder holder : _additionalAdd) | ||||
| 			{ | ||||
| 				if (holder.verifyCondition(_creature)) | ||||
| 				{ | ||||
| 					mergeAdd(holder.getStat(), holder.getValue()); | ||||
| 				} | ||||
| 			} | ||||
| 			for (StatHolder holder : _additionalMul) | ||||
| 			{ | ||||
| 				if (holder.verifyCondition(_creature)) | ||||
| 				{ | ||||
| 					mergeMul(holder.getStat(), holder.getValue()); | ||||
| 				} | ||||
| 			} | ||||
| 			_attackSpeedMultiplier = Formulas.calcAtkSpdMultiplier(_creature); | ||||
| 			_mAttackSpeedMultiplier = Formulas.calcMAtkSpdMultiplier(_creature); | ||||
| 		} | ||||
|   | ||||
| @@ -18,11 +18,11 @@ package org.l2jmobius.gameserver.model.actor.transform; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.l2jmobius.gameserver.data.xml.impl.SkillTreeData; | ||||
| import org.l2jmobius.gameserver.enums.InventoryBlockType; | ||||
| import org.l2jmobius.gameserver.enums.Sex; | ||||
| import org.l2jmobius.gameserver.model.SkillLearn; | ||||
| import org.l2jmobius.gameserver.model.StatSet; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| import org.l2jmobius.gameserver.model.actor.Npc; | ||||
| @@ -35,6 +35,7 @@ import org.l2jmobius.gameserver.model.holders.SkillHolder; | ||||
| import org.l2jmobius.gameserver.model.interfaces.IIdentifiable; | ||||
| import org.l2jmobius.gameserver.model.items.type.WeaponType; | ||||
| import org.l2jmobius.gameserver.model.skills.AbnormalType; | ||||
| import org.l2jmobius.gameserver.model.skills.Skill; | ||||
| import org.l2jmobius.gameserver.model.stats.Stat; | ||||
| import org.l2jmobius.gameserver.network.serverpackets.ExBasicActionList; | ||||
| import org.l2jmobius.gameserver.network.serverpackets.ExUserInfoEquipSlot; | ||||
| @@ -259,27 +260,30 @@ public class Transform implements IIdentifiable | ||||
| 				 | ||||
| 				if (addSkills) | ||||
| 				{ | ||||
| 					//@formatter:off | ||||
| 					// Add common skills. | ||||
| 					template.getSkills() | ||||
| 						.stream() | ||||
| 						.map(SkillHolder::getSkill) | ||||
| 						.forEach(player::addTransformSkill); | ||||
| 					for (SkillHolder h : template.getSkills()) | ||||
| 					{ | ||||
| 						player.addTransformSkill(h.getSkill()); | ||||
| 					} | ||||
| 					 | ||||
| 					// Add skills depending on level. | ||||
| 					template.getAdditionalSkills() | ||||
| 						.stream() | ||||
| 						.filter(h -> player.getLevel() >= h.getMinLevel()) | ||||
| 						.map(SkillHolder::getSkill) | ||||
| 						.forEach(player::addTransformSkill); | ||||
| 					for (AdditionalSkillHolder h : template.getAdditionalSkills()) | ||||
| 					{ | ||||
| 						if (player.getLevel() >= h.getMinLevel()) | ||||
| 						{ | ||||
| 							player.addTransformSkill(h.getSkill()); | ||||
| 						} | ||||
| 					} | ||||
| 					 | ||||
| 					// Add collection skills. | ||||
| 					SkillTreeData.getInstance().getCollectSkillTree().values() | ||||
| 						.stream() | ||||
| 						.map(s -> player.getKnownSkill(s.getSkillId())) | ||||
| 						.filter(Objects::nonNull) | ||||
| 						.forEach(player::addTransformSkill); | ||||
| 					//@formatter:on | ||||
| 					for (SkillLearn s : SkillTreeData.getInstance().getCollectSkillTree().values()) | ||||
| 					{ | ||||
| 						final Skill skill = player.getKnownSkill(s.getSkillId()); | ||||
| 						if (skill != null) | ||||
| 						{ | ||||
| 							player.addTransformSkill(skill); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				 | ||||
| 				// Set inventory blocks if needed. | ||||
|   | ||||
| @@ -276,7 +276,13 @@ public class CeremonyOfChaosEvent extends AbstractEvent<CeremonyOfChaosMember> | ||||
| 	 | ||||
| 	public void stopFight() | ||||
| 	{ | ||||
| 		getMembers().values().stream().filter(p -> p.getLifeTime() == 0).forEach(this::updateLifeTime); | ||||
| 		for (CeremonyOfChaosMember member : getMembers().values()) | ||||
| 		{ | ||||
| 			if (member.getLifeTime() == 0) | ||||
| 			{ | ||||
| 				updateLifeTime(member); | ||||
| 			} | ||||
| 		} | ||||
| 		validateWinner(); | ||||
| 		 | ||||
| 		final List<CeremonyOfChaosMember> winners = getWinners(); | ||||
| @@ -497,7 +503,15 @@ public class CeremonyOfChaosEvent extends AbstractEvent<CeremonyOfChaosMember> | ||||
| 				getMembers().values().forEach(p -> broadcastPacket(new ExCuriousHouseMemberUpdate(p))); | ||||
| 				 | ||||
| 				// Validate winner | ||||
| 				if (getMembers().values().stream().filter(member -> !member.isDefeated()).count() <= 1) | ||||
| 				int count = 0; | ||||
| 				for (CeremonyOfChaosMember member : getMembers().values()) | ||||
| 				{ | ||||
| 					if (!member.isDefeated()) | ||||
| 					{ | ||||
| 						count++; | ||||
| 					} | ||||
| 				} | ||||
| 				if (count <= 1) | ||||
| 				{ | ||||
| 					stopFight(); | ||||
| 				} | ||||
| @@ -595,12 +609,13 @@ public class CeremonyOfChaosEvent extends AbstractEvent<CeremonyOfChaosMember> | ||||
| 				targetMember.setDefeated(true); | ||||
| 				 | ||||
| 				// Delete target player | ||||
| 				//@formatter:off | ||||
| 				getMembers().values().stream() | ||||
| 					.filter(member -> member.getObjectId() != targetPlayer.getObjectId()) | ||||
| 					.map(CeremonyOfChaosMember::getPlayer) | ||||
| 					.forEach(deleteObject::sendTo); | ||||
| 				//@formatter:on | ||||
| 				for (CeremonyOfChaosMember member : getMembers().values()) | ||||
| 				{ | ||||
| 					if (member.getObjectId() != targetPlayer.getObjectId()) | ||||
| 					{ | ||||
| 						deleteObject.sendTo(member.getPlayer()); | ||||
| 					} | ||||
| 				} | ||||
| 				 | ||||
| 				// Make the target observer | ||||
| 				targetPlayer.setObserving(true); | ||||
|   | ||||
| @@ -20,17 +20,16 @@ import java.sql.Connection; | ||||
| import java.sql.PreparedStatement; | ||||
| import java.sql.ResultSet; | ||||
| import java.sql.SQLException; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Objects; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.ConcurrentSkipListMap; | ||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.concurrent.ThreadPool; | ||||
| @@ -663,14 +662,15 @@ public class Clan implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public List<PlayerInstance> getOnlineMembers(int exclude) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return _members.values().stream() | ||||
| 			.filter(member -> member.getObjectId() != exclude) | ||||
| 			.filter(ClanMember::isOnline) | ||||
| 			.map(ClanMember::getPlayerInstance) | ||||
| 			.filter(Objects::nonNull) | ||||
| 			.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		final List<PlayerInstance> result = new ArrayList<>(); | ||||
| 		for (ClanMember member : _members.values()) | ||||
| 		{ | ||||
| 			if ((member.getObjectId() != exclude) && member.isOnline() && (member.getPlayerInstance() != null)) | ||||
| 			{ | ||||
| 				result.add(member.getPlayerInstance()); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -678,11 +678,15 @@ public class Clan implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public int getOnlineMembersCount() | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return (int) _members.values().stream() | ||||
| 			.filter(ClanMember::isOnline) | ||||
| 			.count(); | ||||
| 		//@formatter:on | ||||
| 		int count = 0; | ||||
| 		for (ClanMember member : _members.values()) | ||||
| 		{ | ||||
| 			if (member.isOnline()) | ||||
| 			{ | ||||
| 				count++; | ||||
| 			} | ||||
| 		} | ||||
| 		return count; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -2907,7 +2911,14 @@ public class Clan implements IIdentifiable, INamable | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		final int currentMaxOnline = (int) _members.values().stream().filter(member -> member.getOnlineTime() > Config.ALT_CLAN_MEMBERS_TIME_FOR_BONUS).count(); | ||||
| 		int currentMaxOnline = 0; | ||||
| 		for (ClanMember member : _members.values()) | ||||
| 		{ | ||||
| 			if (member.getOnlineTime() > Config.ALT_CLAN_MEMBERS_TIME_FOR_BONUS) | ||||
| 			{ | ||||
| 				currentMaxOnline++; | ||||
| 			} | ||||
| 		} | ||||
| 		if (getMaxOnlineMembers() < currentMaxOnline) | ||||
| 		{ | ||||
| 			getVariables().set("MAX_ONLINE_MEMBERS", currentMaxOnline); | ||||
|   | ||||
| @@ -23,7 +23,6 @@ import java.util.ArrayList; | ||||
| import java.util.Calendar; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Objects; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| @@ -889,12 +888,26 @@ public class Castle extends AbstractResidence | ||||
| 	 | ||||
| 	public DoorInstance getDoor(int doorId) | ||||
| 	{ | ||||
| 		return _doors.stream().filter(d -> d.getId() == doorId).findFirst().orElse(null); | ||||
| 		for (DoorInstance door : _doors) | ||||
| 		{ | ||||
| 			if (door.getId() == doorId) | ||||
| 			{ | ||||
| 				return door; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public DoorInstance getDoor(String doorName) | ||||
| 	{ | ||||
| 		return _doors.stream().filter(d -> d.getTemplate().getName().equals(doorName)).findFirst().orElse(null); | ||||
| 		for (DoorInstance door : _doors) | ||||
| 		{ | ||||
| 			if (door.getTemplate().getName().equals(doorName)) | ||||
| 			{ | ||||
| 				return door; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public List<DoorInstance> getDoors() | ||||
| @@ -1162,7 +1175,13 @@ public class Castle extends AbstractResidence | ||||
| 	 | ||||
| 	public void spawnSideNpcs() | ||||
| 	{ | ||||
| 		_sideNpcs.stream().filter(Objects::nonNull).forEach(Npc::deleteMe); | ||||
| 		for (Npc npc : _sideNpcs) | ||||
| 		{ | ||||
| 			if (npc != null) | ||||
| 			{ | ||||
| 				npc.deleteMe(); | ||||
| 			} | ||||
| 		} | ||||
| 		_sideNpcs.clear(); | ||||
| 		 | ||||
| 		for (CastleSpawnHolder holder : getSideSpawns()) | ||||
|   | ||||
| @@ -22,12 +22,12 @@ import java.sql.ResultSet; | ||||
| import java.sql.SQLException; | ||||
| import java.time.Duration; | ||||
| import java.time.Instant; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.ScheduledFuture; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.commons.concurrent.ThreadPool; | ||||
| import org.l2jmobius.commons.database.DatabaseFactory; | ||||
| @@ -150,10 +150,13 @@ public class ClanHall extends AbstractResidence | ||||
| 	@Override | ||||
| 	protected void initResidenceZone() | ||||
| 	{ | ||||
| 		final ClanHallZone zone = ZoneManager.getInstance().getAllZones(ClanHallZone.class).stream().filter(z -> z.getResidenceId() == getResidenceId()).findFirst().orElse(null); | ||||
| 		if (zone != null) | ||||
| 		for (ClanHallZone zone : ZoneManager.getInstance().getAllZones(ClanHallZone.class)) | ||||
| 		{ | ||||
| 			setResidenceZone(zone); | ||||
| 			if (zone.getResidenceId() == getResidenceId()) | ||||
| 			{ | ||||
| 				setResidenceZone(zone); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| @@ -328,7 +331,15 @@ public class ClanHall extends AbstractResidence | ||||
| 	 | ||||
| 	public List<ClanHallTeleportHolder> getTeleportList(int functionLevel) | ||||
| 	{ | ||||
| 		return _teleports.stream().filter(holder -> holder.getMinFunctionLevel() <= functionLevel).collect(Collectors.toList()); | ||||
| 		final List<ClanHallTeleportHolder> result = new ArrayList<>(); | ||||
| 		for (ClanHallTeleportHolder holder : _teleports) | ||||
| 		{ | ||||
| 			if (holder.getMinFunctionLevel() <= functionLevel) | ||||
| 			{ | ||||
| 				result.add(holder); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public int getMinBid() | ||||
|   | ||||
| @@ -610,8 +610,15 @@ public class Duel | ||||
| 		} | ||||
| 		 | ||||
| 		final int instanceId = DuelManager.getInstance().getDuelArena(); | ||||
| 		final OlympiadStadiumZone zone = ZoneManager.getInstance().getAllZones(OlympiadStadiumZone.class) // | ||||
| 			.stream().filter(z -> z.getInstanceTemplateId() == instanceId).findFirst().orElse(null); | ||||
| 		OlympiadStadiumZone zone = null; | ||||
| 		for (OlympiadStadiumZone z : ZoneManager.getInstance().getAllZones(OlympiadStadiumZone.class)) | ||||
| 		{ | ||||
| 			if (z.getInstanceTemplateId() == instanceId) | ||||
| 			{ | ||||
| 				zone = z; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		if (zone == null) | ||||
| 		{ | ||||
| 			throw new RuntimeException("Unable to find a party duel arena!"); | ||||
|   | ||||
| @@ -25,13 +25,11 @@ import java.util.Collection; | ||||
| import java.util.Collections; | ||||
| import java.util.Iterator; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.Set; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.concurrent.ScheduledFuture; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.concurrent.ThreadPool; | ||||
| @@ -790,14 +788,22 @@ public class Siege implements Siegable | ||||
| 	@Override | ||||
| 	public List<PlayerInstance> getAttackersInZone() | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return getAttackerClans().stream() | ||||
| 			.map(siegeclan -> ClanTable.getInstance().getClan(siegeclan.getClanId())) | ||||
| 			.filter(Objects::nonNull) | ||||
| 			.flatMap(clan -> clan.getOnlineMembers(0).stream()) | ||||
| 			.filter(PlayerInstance::isInSiege) | ||||
| 			.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		final List<PlayerInstance> result = new ArrayList<>(); | ||||
| 		for (SiegeClan siegeclan : getAttackerClans()) | ||||
| 		{ | ||||
| 			final Clan clan = ClanTable.getInstance().getClan(siegeclan.getClanId()); | ||||
| 			if (clan != null) | ||||
| 			{ | ||||
| 				for (PlayerInstance member : clan.getOnlineMembers(0)) | ||||
| 				{ | ||||
| 					if (member.isInSiege()) | ||||
| 					{ | ||||
| 						result.add(member); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -813,15 +819,25 @@ public class Siege implements Siegable | ||||
| 	 */ | ||||
| 	public List<PlayerInstance> getOwnersInZone() | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		return getDefenderClans().stream() | ||||
| 			.filter(siegeclan -> siegeclan.getClanId() == _castle.getOwnerId()) | ||||
| 			.map(siegeclan -> ClanTable.getInstance().getClan(siegeclan.getClanId())) | ||||
| 			.filter(Objects::nonNull) | ||||
| 			.flatMap(clan -> clan.getOnlineMembers(0).stream()) | ||||
| 			.filter(PlayerInstance::isInSiege) | ||||
| 			.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		final List<PlayerInstance> result = new ArrayList<>(); | ||||
| 		for (SiegeClan siegeclan : getDefenderClans()) | ||||
| 		{ | ||||
| 			if (siegeclan.getClanId() == _castle.getOwnerId()) | ||||
| 			{ | ||||
| 				final Clan clan = ClanTable.getInstance().getClan(siegeclan.getClanId()); | ||||
| 				if (clan != null) | ||||
| 				{ | ||||
| 					for (PlayerInstance member : clan.getOnlineMembers(0)) | ||||
| 					{ | ||||
| 						if (member.isInSiege()) | ||||
| 						{ | ||||
| 							result.add(member); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -829,7 +845,15 @@ public class Siege implements Siegable | ||||
| 	 */ | ||||
| 	public List<PlayerInstance> getSpectatorsInZone() | ||||
| 	{ | ||||
| 		return _castle.getZone().getPlayersInside().stream().filter(p -> !p.isInSiege()).collect(Collectors.toList()); | ||||
| 		final List<PlayerInstance> result = new ArrayList<>(); | ||||
| 		for (PlayerInstance player : _castle.getZone().getPlayersInside()) | ||||
| 		{ | ||||
| 			if (!player.isInSiege()) | ||||
| 			{ | ||||
| 				result.add(player); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -81,7 +81,14 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab | ||||
| 	 | ||||
| 	public EventScheduler getScheduler(String name) | ||||
| 	{ | ||||
| 		return _schedulers.stream().filter(scheduler -> scheduler.getName().equalsIgnoreCase(name)).findFirst().orElse(null); | ||||
| 		for (EventScheduler scheduler : _schedulers) | ||||
| 		{ | ||||
| 			if (scheduler.getName().equalsIgnoreCase(name)) | ||||
| 			{ | ||||
| 				return scheduler; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public void setSchedulers(Set<EventScheduler> schedulers) | ||||
| @@ -134,11 +141,13 @@ public abstract class AbstractEventManager<T extends AbstractEvent<?>>extends Ab | ||||
| 	 | ||||
| 	public void startConditionalSchedulers() | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		_conditionalSchedulers.stream() | ||||
| 			.filter(IConditionalEventScheduler::test) | ||||
| 			.forEach(IConditionalEventScheduler::run); | ||||
| 		//@formatter:on | ||||
| 		for (IConditionalEventScheduler scheduler : _conditionalSchedulers) | ||||
| 		{ | ||||
| 			if (scheduler.test()) | ||||
| 			{ | ||||
| 				scheduler.run(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	/* ********************** */ | ||||
|   | ||||
| @@ -82,14 +82,29 @@ public class ListenersContainer | ||||
| 	 | ||||
| 	public void removeListenerIf(EventType type, Predicate<? super AbstractEventListener> filter) | ||||
| 	{ | ||||
| 		getListeners(type).stream().filter(filter).forEach(AbstractEventListener::unregisterMe); | ||||
| 		for (AbstractEventListener listener : getListeners(type)) | ||||
| 		{ | ||||
| 			if (filter.test(listener)) | ||||
| 			{ | ||||
| 				listener.unregisterMe(); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void removeListenerIf(Predicate<? super AbstractEventListener> filter) | ||||
| 	{ | ||||
| 		if (_listeners != null) | ||||
| 		{ | ||||
| 			getListeners().values().forEach(queue -> queue.stream().filter(filter).forEach(AbstractEventListener::unregisterMe)); | ||||
| 			for (Queue<AbstractEventListener> queue : getListeners().values()) | ||||
| 			{ | ||||
| 				for (AbstractEventListener listener : queue) | ||||
| 				{ | ||||
| 					if (filter.test(listener)) | ||||
| 					{ | ||||
| 						listener.unregisterMe(); | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -57,11 +57,17 @@ public class PreparedMultisellListHolder extends MultisellListHolder | ||||
| 			inventory.getItems(item -> !item.isEquipped() && (item.isArmor() || item.isWeapon())).forEach(item -> | ||||
| 			{ | ||||
| 				// Check ingredients of each entry to see if it's an entry we'd like to include. | ||||
| 				list.getEntries().stream().filter(e -> e.getIngredients().stream().anyMatch(i -> i.getId() == item.getId())).forEach(e -> | ||||
| 				for (MultisellEntryHolder entry : list.getEntries()) | ||||
| 				{ | ||||
| 					_entries.add(e); | ||||
| 					_itemInfos.add(new ItemInfo(item)); | ||||
| 				}); | ||||
| 					for (ItemChanceHolder holder : entry.getIngredients()) | ||||
| 					{ | ||||
| 						if (holder.getId() == item.getId()) | ||||
| 						{ | ||||
| 							_entries.add(entry); | ||||
| 							_itemInfos.add(new ItemInfo(item)); | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 			}); | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
| @@ -119,8 +119,15 @@ public class Instance implements IIdentifiable, INamable | ||||
| 		setStatus(0); | ||||
| 		spawnDoors(); | ||||
| 		 | ||||
| 		// initialize instance spawns | ||||
| 		_spawns.stream().filter(SpawnTemplate::isSpawningByDefault).forEach(spawnTemplate -> spawnTemplate.spawnAll(this)); | ||||
| 		// Initialize instance spawns. | ||||
| 		for (SpawnTemplate spawnTemplate : _spawns) | ||||
| 		{ | ||||
| 			if (spawnTemplate.isSpawningByDefault()) | ||||
| 			{ | ||||
| 				spawnTemplate.spawnAll(this); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (!isDynamic()) | ||||
| 		{ | ||||
| 			// Notify DP scripts | ||||
| @@ -325,7 +332,11 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public PlayerInstance getFirstPlayer() | ||||
| 	{ | ||||
| 		return _players.stream().findFirst().orElse(null); | ||||
| 		for (PlayerInstance player : _players) | ||||
| 		{ | ||||
| 			return player; | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -335,7 +346,14 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public PlayerInstance getPlayerById(int id) | ||||
| 	{ | ||||
| 		return _players.stream().filter(p -> p.getObjectId() == id).findFirst().orElse(null); | ||||
| 		for (PlayerInstance player : _players) | ||||
| 		{ | ||||
| 			if (player.getObjectId() == id) | ||||
| 			{ | ||||
| 				return player; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -344,9 +362,17 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 * @param radius radius around target | ||||
| 	 * @return players within radius | ||||
| 	 */ | ||||
| 	public Set<PlayerInstance> getPlayersInsideRadius(ILocational object, int radius) | ||||
| 	public List<PlayerInstance> getPlayersInsideRadius(ILocational object, int radius) | ||||
| 	{ | ||||
| 		return _players.stream().filter(p -> p.isInsideRadius3D(object, radius)).collect(Collectors.toSet()); | ||||
| 		final List<PlayerInstance> result = new ArrayList<>(); | ||||
| 		for (PlayerInstance player : _players) | ||||
| 		{ | ||||
| 			if (player.isInsideRadius3D(object, radius)) | ||||
| 			{ | ||||
| 				result.add(player); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -543,9 +569,17 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 * Get alive NPCs from instance. | ||||
| 	 * @return set of NPCs from instance | ||||
| 	 */ | ||||
| 	public Set<Npc> getAliveNpcs() | ||||
| 	public List<Npc> getAliveNpcs() | ||||
| 	{ | ||||
| 		return _npcs.stream().filter(n -> n.getCurrentHp() > 0).collect(Collectors.toSet()); | ||||
| 		final List<Npc> result = new ArrayList<>(); | ||||
| 		for (Npc npc : _npcs) | ||||
| 		{ | ||||
| 			if (npc.getCurrentHp() > 0) | ||||
| 			{ | ||||
| 				result.add(npc); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -555,7 +589,15 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public List<Npc> getNpcs(int... id) | ||||
| 	{ | ||||
| 		return _npcs.stream().filter(n -> CommonUtil.contains(id, n.getId())).collect(Collectors.toList()); | ||||
| 		final List<Npc> result = new ArrayList<>(); | ||||
| 		for (Npc npc : _npcs) | ||||
| 		{ | ||||
| 			if (CommonUtil.contains(id, npc.getId())) | ||||
| 			{ | ||||
| 				result.add(npc); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -566,9 +608,18 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 * @return list of filtered NPCs from instance | ||||
| 	 */ | ||||
| 	@SafeVarargs | ||||
| 	@SuppressWarnings("unchecked") | ||||
| 	public final <T extends Creature> List<T> getNpcs(Class<T> clazz, int... ids) | ||||
| 	{ | ||||
| 		return _npcs.stream().filter(n -> (ids.length == 0) || CommonUtil.contains(ids, n.getId())).filter(clazz::isInstance).map(clazz::cast).collect(Collectors.toList()); | ||||
| 		final List<T> result = new ArrayList<>(); | ||||
| 		for (Npc npc : _npcs) | ||||
| 		{ | ||||
| 			if (((ids.length == 0) || CommonUtil.contains(ids, npc.getId())) && clazz.isInstance(npc)) | ||||
| 			{ | ||||
| 				result.add((T) npc); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -579,9 +630,18 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 * @return list of filtered NPCs from instance | ||||
| 	 */ | ||||
| 	@SafeVarargs | ||||
| 	@SuppressWarnings("unchecked") | ||||
| 	public final <T extends Creature> List<T> getAliveNpcs(Class<T> clazz, int... ids) | ||||
| 	{ | ||||
| 		return _npcs.stream().filter(n -> ((ids.length == 0) || CommonUtil.contains(ids, n.getId())) && (n.getCurrentHp() > 0)).filter(clazz::isInstance).map(clazz::cast).collect(Collectors.toList()); | ||||
| 		final List<T> result = new ArrayList<>(); | ||||
| 		for (Npc npc : _npcs) | ||||
| 		{ | ||||
| 			if ((((ids.length == 0) || CommonUtil.contains(ids, npc.getId())) && (npc.getCurrentHp() > 0)) && clazz.isInstance(npc)) | ||||
| 			{ | ||||
| 				result.add((T) npc); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -591,7 +651,15 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public List<Npc> getAliveNpcs(int... id) | ||||
| 	{ | ||||
| 		return _npcs.stream().filter(n -> (n.getCurrentHp() > 0) && CommonUtil.contains(id, n.getId())).collect(Collectors.toList()); | ||||
| 		final List<Npc> result = new ArrayList<>(); | ||||
| 		for (Npc npc : _npcs) | ||||
| 		{ | ||||
| 			if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId())) | ||||
| 			{ | ||||
| 				result.add(npc); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -601,7 +669,14 @@ public class Instance implements IIdentifiable, INamable | ||||
| 	 */ | ||||
| 	public Npc getNpc(int id) | ||||
| 	{ | ||||
| 		return _npcs.stream().filter(n -> n.getId() == id).findFirst().orElse(null); | ||||
| 		for (Npc npc : _npcs) | ||||
| 		{ | ||||
| 			if (npc.getId() == id) | ||||
| 			{ | ||||
| 				return npc; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	public void addNpc(Npc npc) | ||||
|   | ||||
| @@ -676,7 +676,13 @@ public class InstanceTemplate extends ListenersContainer implements IIdentifiabl | ||||
| 		// If any group found then put them into enter group list | ||||
| 		if (pGroup != null) | ||||
| 		{ | ||||
| 			pGroup.getMembers().stream().filter(p -> !p.equals(player)).forEach(group::add); | ||||
| 			for (PlayerInstance member : pGroup.getMembers()) | ||||
| 			{ | ||||
| 				if (!member.equals(player)) | ||||
| 				{ | ||||
| 					group.add(member); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		return group; | ||||
| 	} | ||||
|   | ||||
| @@ -19,14 +19,14 @@ package org.l2jmobius.gameserver.model.itemcontainer; | ||||
| import java.sql.Connection; | ||||
| import java.sql.PreparedStatement; | ||||
| import java.sql.ResultSet; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.function.Predicate; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.database.DatabaseFactory; | ||||
| @@ -89,7 +89,16 @@ public abstract class ItemContainer | ||||
| 		{ | ||||
| 			filter = filter.and(additionalFilter); | ||||
| 		} | ||||
| 		return (int) _items.values().stream().filter(filter).count(); | ||||
| 		 | ||||
| 		int count = 0; | ||||
| 		for (ItemInstance item : _items.values()) | ||||
| 		{ | ||||
| 			if (filter.test(item)) | ||||
| 			{ | ||||
| 				count++; | ||||
| 			} | ||||
| 		} | ||||
| 		return count; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -115,7 +124,16 @@ public abstract class ItemContainer | ||||
| 		{ | ||||
| 			filter = filter.and(additionalFilter); | ||||
| 		} | ||||
| 		return _items.values().stream().filter(filter).collect(Collectors.toCollection(LinkedList::new)); | ||||
| 		 | ||||
| 		final List<ItemInstance> result = new ArrayList<>(); | ||||
| 		for (ItemInstance item : _items.values()) | ||||
| 		{ | ||||
| 			if (filter.test(item)) | ||||
| 			{ | ||||
| 				result.add(item); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -124,7 +142,14 @@ public abstract class ItemContainer | ||||
| 	 */ | ||||
| 	public ItemInstance getItemByItemId(int itemId) | ||||
| 	{ | ||||
| 		return _items.values().stream().filter(item -> item.getId() == itemId).findFirst().orElse(null); | ||||
| 		for (ItemInstance item : _items.values()) | ||||
| 		{ | ||||
| 			if (item.getId() == itemId) | ||||
| 			{ | ||||
| 				return item; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
|   | ||||
| @@ -26,7 +26,6 @@ import java.util.Map; | ||||
| import java.util.function.Consumer; | ||||
| import java.util.function.Predicate; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.gameserver.datatables.ItemTable; | ||||
| @@ -755,7 +754,20 @@ public abstract class Item extends ListenersContainer implements IIdentifiable | ||||
| 	 */ | ||||
| 	public List<ItemSkillHolder> getSkills(Predicate<ItemSkillHolder> condition) | ||||
| 	{ | ||||
| 		return _skills != null ? _skills.stream().filter(condition).collect(Collectors.toList()) : null; | ||||
| 		if (_skills == null) | ||||
| 		{ | ||||
| 			return null; | ||||
| 		} | ||||
| 		 | ||||
| 		final List<ItemSkillHolder> result = new ArrayList<>(); | ||||
| 		for (ItemSkillHolder skill : _skills) | ||||
| 		{ | ||||
| 			if (condition.test(skill)) | ||||
| 			{ | ||||
| 				result.add(skill); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -764,7 +776,20 @@ public abstract class Item extends ListenersContainer implements IIdentifiable | ||||
| 	 */ | ||||
| 	public List<ItemSkillHolder> getSkills(ItemSkillType type) | ||||
| 	{ | ||||
| 		return _skills != null ? _skills.stream().filter(sk -> sk.getType() == type).collect(Collectors.toList()) : null; | ||||
| 		if (_skills == null) | ||||
| 		{ | ||||
| 			return null; | ||||
| 		} | ||||
| 		 | ||||
| 		final List<ItemSkillHolder> result = new ArrayList<>(); | ||||
| 		for (ItemSkillHolder skill : _skills) | ||||
| 		{ | ||||
| 			if (skill.getType() == type) | ||||
| 			{ | ||||
| 				result.add(skill); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -776,7 +801,13 @@ public abstract class Item extends ListenersContainer implements IIdentifiable | ||||
| 	{ | ||||
| 		if (_skills != null) | ||||
| 		{ | ||||
| 			_skills.stream().filter(sk -> sk.getType() == type).forEach(action); | ||||
| 			for (ItemSkillHolder skill : _skills) | ||||
| 			{ | ||||
| 				if (skill.getType() == type) | ||||
| 				{ | ||||
| 					action.accept(skill); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -56,13 +56,25 @@ public class CommandChannelMatchingRoom extends MatchingRoom | ||||
| 	@Override | ||||
| 	protected void notifyNewMember(PlayerInstance player) | ||||
| 	{ | ||||
| 		// Update others player | ||||
| 		getMembers().stream().filter(p -> p != player).forEach(p -> p.sendPacket(new ExManageMpccRoomMember(p, this, ExManagePartyRoomMemberType.ADD_MEMBER))); | ||||
| 		// Update other players | ||||
| 		for (PlayerInstance member : getMembers()) | ||||
| 		{ | ||||
| 			if (member != player) | ||||
| 			{ | ||||
| 				member.sendPacket(new ExManageMpccRoomMember(member, this, ExManagePartyRoomMemberType.ADD_MEMBER)); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// Send SystemMessage to others player | ||||
| 		// Send SystemMessage to other players | ||||
| 		final SystemMessage sm = new SystemMessage(SystemMessageId.C1_ENTERED_THE_COMMAND_CHANNEL_MATCHING_ROOM); | ||||
| 		sm.addPcName(player); | ||||
| 		getMembers().stream().filter(p -> p != player).forEach(sm::sendTo); | ||||
| 		for (PlayerInstance member : getMembers()) | ||||
| 		{ | ||||
| 			if (member != player) | ||||
| 			{ | ||||
| 				sm.sendTo(member); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// Update new player | ||||
| 		player.sendPacket(new ExMPCCRoomInfo(this)); | ||||
|   | ||||
| @@ -57,13 +57,25 @@ public class PartyMatchingRoom extends MatchingRoom | ||||
| 	@Override | ||||
| 	protected void notifyNewMember(PlayerInstance player) | ||||
| 	{ | ||||
| 		// Update others player | ||||
| 		getMembers().stream().filter(p -> p != player).forEach(p -> p.sendPacket(new ExPartyRoomMember(p, this))); | ||||
| 		// Update other players | ||||
| 		for (PlayerInstance member : getMembers()) | ||||
| 		{ | ||||
| 			if (member != player) | ||||
| 			{ | ||||
| 				member.sendPacket(new ExPartyRoomMember(member, this)); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// Send SystemMessage to others player | ||||
| 		// Send SystemMessage to other players | ||||
| 		final SystemMessage sm = new SystemMessage(SystemMessageId.C1_HAS_ENTERED_THE_PARTY_ROOM); | ||||
| 		sm.addPcName(player); | ||||
| 		getMembers().stream().filter(p -> p != player).forEach(sm::sendTo); | ||||
| 		for (PlayerInstance member : getMembers()) | ||||
| 		{ | ||||
| 			if (member != player) | ||||
| 			{ | ||||
| 				sm.sendTo(member); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// Update new player | ||||
| 		player.sendPacket(new PartyRoomInfo(this)); | ||||
|   | ||||
| @@ -328,15 +328,18 @@ public abstract class AbstractOlympiadGame | ||||
| 				pet.getEffectList().stopEffects(info -> info.getSkill().isBlockedInOlympiad(), true, true); | ||||
| 			} | ||||
| 			 | ||||
| 			player.getServitors().values().stream().filter(s -> !s.isDead()).forEach(s -> | ||||
| 			for (Summon s : player.getServitors().values()) | ||||
| 			{ | ||||
| 				s.setTarget(null); | ||||
| 				s.abortAttack(); | ||||
| 				s.abortCast(); | ||||
| 				s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | ||||
| 				s.stopAllEffectsExceptThoseThatLastThroughDeath(); | ||||
| 				s.getEffectList().stopEffects(info -> info.getSkill().isBlockedInOlympiad(), true, true); | ||||
| 			}); | ||||
| 				if (!s.isDead()) | ||||
| 				{ | ||||
| 					s.setTarget(null); | ||||
| 					s.abortAttack(); | ||||
| 					s.abortCast(); | ||||
| 					s.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE); | ||||
| 					s.stopAllEffectsExceptThoseThatLastThroughDeath(); | ||||
| 					s.getEffectList().stopEffects(info -> info.getSkill().isBlockedInOlympiad(), true, true); | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			player.setCurrentCp(player.getMaxCp()); | ||||
| 			player.setCurrentHp(player.getMaxHp()); | ||||
|   | ||||
| @@ -2798,7 +2798,13 @@ public class Quest extends AbstractScript implements IIdentifiable | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			getListeners().stream().filter(listener -> listener.getType() == EventType.ON_PLAYER_LOGIN).forEach(AbstractEventListener::unregisterMe); | ||||
| 			for (AbstractEventListener listener : getListeners()) | ||||
| 			{ | ||||
| 				if (listener.getType() == EventType.ON_PLAYER_LOGIN) | ||||
| 				{ | ||||
| 					listener.unregisterMe(); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -250,7 +250,14 @@ public abstract class AbstractResidence extends ListenersContainer implements IN | ||||
| 	 */ | ||||
| 	public ResidenceFunction getFunction(ResidenceFunctionType type) | ||||
| 	{ | ||||
| 		return _functions.values().stream().filter(func -> func.getType() == type).findFirst().orElse(null); | ||||
| 		for (ResidenceFunction func : _functions.values()) | ||||
| 		{ | ||||
| 			if (func.getType() == type) | ||||
| 			{ | ||||
| 				return func; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -260,7 +267,14 @@ public abstract class AbstractResidence extends ListenersContainer implements IN | ||||
| 	 */ | ||||
| 	public ResidenceFunction getFunction(int id, int level) | ||||
| 	{ | ||||
| 		return _functions.values().stream().filter(func -> (func.getId() == id) && (func.getLevel() == level)).findFirst().orElse(null); | ||||
| 		for (ResidenceFunction func : _functions.values()) | ||||
| 		{ | ||||
| 			if ((func.getId() == id) && (func.getLevel() == level)) | ||||
| 			{ | ||||
| 				return func; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -269,7 +283,14 @@ public abstract class AbstractResidence extends ListenersContainer implements IN | ||||
| 	 */ | ||||
| 	public ResidenceFunction getFunction(int id) | ||||
| 	{ | ||||
| 		return _functions.values().stream().filter(func -> (func.getId() == id)).findFirst().orElse(null); | ||||
| 		for (ResidenceFunction func : _functions.values()) | ||||
| 		{ | ||||
| 			if (func.getId() == id) | ||||
| 			{ | ||||
| 				return func; | ||||
| 			} | ||||
| 		} | ||||
| 		return null; | ||||
| 	} | ||||
| 	 | ||||
| 	/** | ||||
| @@ -288,7 +309,15 @@ public abstract class AbstractResidence extends ListenersContainer implements IN | ||||
| 	 */ | ||||
| 	public long getFunctionExpiration(ResidenceFunctionType type) | ||||
| 	{ | ||||
| 		final ResidenceFunction function = _functions.values().stream().filter(func -> func.getTemplate().getType() == type).findFirst().orElse(null); | ||||
| 		ResidenceFunction function = null; | ||||
| 		for (ResidenceFunction func : _functions.values()) | ||||
| 		{ | ||||
| 			if (func.getTemplate().getType() == type) | ||||
| 			{ | ||||
| 				function = func; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		return function != null ? function.getExpiration() : -1; | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -1710,12 +1710,15 @@ public class Skill implements IIdentifiable | ||||
| 			return null; | ||||
| 		} | ||||
| 		 | ||||
| 		//@formatter:off | ||||
| 		final int toggleSkillId = creature.getEffectList().getEffects().stream() | ||||
| 		.filter(info -> info.getSkill().getToggleGroupId() == _attachToggleGroupId) | ||||
| 		.mapToInt(info -> info.getSkill().getId()) | ||||
| 		.findAny().orElse(0); | ||||
| 		//@formatter:on | ||||
| 		int toggleSkillId = 0; | ||||
| 		for (BuffInfo info : creature.getEffectList().getEffects()) | ||||
| 		{ | ||||
| 			if (info.getSkill().getToggleGroupId() == _attachToggleGroupId) | ||||
| 			{ | ||||
| 				toggleSkillId = info.getSkill().getId(); | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// No active toggles with this toggle group ID found. | ||||
| 		if (toggleSkillId == 0) | ||||
| @@ -1723,7 +1726,15 @@ public class Skill implements IIdentifiable | ||||
| 			return null; | ||||
| 		} | ||||
| 		 | ||||
| 		final AttachSkillHolder attachedSkill = _attachSkills.stream().filter(ash -> ash.getRequiredSkillId() == toggleSkillId).findAny().orElse(null); | ||||
| 		AttachSkillHolder attachedSkill = null; | ||||
| 		for (AttachSkillHolder ash : _attachSkills) | ||||
| 		{ | ||||
| 			if (ash.getRequiredSkillId() == toggleSkillId) | ||||
| 			{ | ||||
| 				attachedSkill = ash; | ||||
| 				break; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		// No attached skills for this toggle found. | ||||
| 		if (attachedSkill == null) | ||||
|   | ||||
| @@ -19,7 +19,6 @@ package org.l2jmobius.gameserver.model.spawns; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.gameserver.model.StatSet; | ||||
| import org.l2jmobius.gameserver.model.instancezone.Instance; | ||||
| @@ -117,7 +116,15 @@ public class SpawnGroup implements Cloneable, ITerritorized, IParameterized<Stat | ||||
| 	 | ||||
| 	public List<NpcSpawnTemplate> getSpawnsById(int id) | ||||
| 	{ | ||||
| 		return _spawns.stream().filter(spawn -> spawn.getId() == id).collect(Collectors.toList()); | ||||
| 		List<NpcSpawnTemplate> result = new ArrayList<>(); | ||||
| 		for (NpcSpawnTemplate spawn : _spawns) | ||||
| 		{ | ||||
| 			if (spawn.getId() == id) | ||||
| 			{ | ||||
| 				result.add(spawn); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	public void spawnAll() | ||||
|   | ||||
| @@ -22,7 +22,6 @@ import java.util.Collections; | ||||
| import java.util.List; | ||||
| import java.util.function.Consumer; | ||||
| import java.util.function.Predicate; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.gameserver.instancemanager.QuestManager; | ||||
| import org.l2jmobius.gameserver.model.StatSet; | ||||
| @@ -124,7 +123,15 @@ public class SpawnTemplate implements Cloneable, ITerritorized, IParameterized<S | ||||
| 	 | ||||
| 	public List<SpawnGroup> getGroupsByName(String name) | ||||
| 	{ | ||||
| 		return _groups.stream().filter(group -> String.valueOf(group.getName()).equalsIgnoreCase(name)).collect(Collectors.toList()); | ||||
| 		final List<SpawnGroup> result = new ArrayList<>(); | ||||
| 		for (SpawnGroup group : _groups) | ||||
| 		{ | ||||
| 			if (String.valueOf(group.getName()).equalsIgnoreCase(name)) | ||||
| 			{ | ||||
| 				result.add(group); | ||||
| 			} | ||||
| 		} | ||||
| 		return result; | ||||
| 	} | ||||
| 	 | ||||
| 	@Override | ||||
| @@ -153,7 +160,13 @@ public class SpawnTemplate implements Cloneable, ITerritorized, IParameterized<S | ||||
| 	 | ||||
| 	public void spawn(Predicate<SpawnGroup> groupFilter, Instance instance) | ||||
| 	{ | ||||
| 		_groups.stream().filter(groupFilter).forEach(group -> group.spawnAll(instance)); | ||||
| 		for (SpawnGroup group : _groups) | ||||
| 		{ | ||||
| 			if (groupFilter.test(group)) | ||||
| 			{ | ||||
| 				group.spawnAll(instance); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	public void spawnAll() | ||||
| @@ -178,7 +191,13 @@ public class SpawnTemplate implements Cloneable, ITerritorized, IParameterized<S | ||||
| 	 | ||||
| 	public void despawn(Predicate<SpawnGroup> groupFilter) | ||||
| 	{ | ||||
| 		_groups.stream().filter(groupFilter).forEach(SpawnGroup::despawnAll); | ||||
| 		for (SpawnGroup group : _groups) | ||||
| 		{ | ||||
| 			if (groupFilter.test(group)) | ||||
| 			{ | ||||
| 				group.despawnAll(); | ||||
| 			} | ||||
| 		} | ||||
| 		notifyEvent(script -> script.onSpawnDeactivate(this)); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
| @@ -20,7 +20,6 @@ import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Objects; | ||||
| import java.util.concurrent.ConcurrentHashMap; | ||||
| import java.util.logging.Logger; | ||||
|  | ||||
| @@ -602,16 +601,15 @@ public abstract class ZoneType extends ListenersContainer | ||||
| 	 | ||||
| 	public void oustAllPlayers() | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		_characterList.values().stream() | ||||
| 			.filter(Objects::nonNull) | ||||
| 			.filter(WorldObject::isPlayer) | ||||
| 			.map(WorldObject::getActingPlayer) | ||||
| 			.filter(PlayerInstance::isOnline) | ||||
| 			.forEach(player -> player.teleToLocation(TeleportWhereType.TOWN)); | ||||
| 		//@formatter:off | ||||
| 		for (Creature obj : _characterList.values()) | ||||
| 		{ | ||||
| 			if ((obj != null) && obj.isPlayer() && obj.getActingPlayer().isOnline()) | ||||
| 			{ | ||||
| 				obj.getActingPlayer().teleToLocation(TeleportWhereType.TOWN); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
| 	/** | ||||
| 	 * @param loc | ||||
| 	 */ | ||||
|   | ||||
| @@ -16,8 +16,6 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.network.clientpackets; | ||||
|  | ||||
| import java.util.OptionalInt; | ||||
|  | ||||
| import org.l2jmobius.commons.network.PacketReader; | ||||
| import org.l2jmobius.gameserver.instancemanager.ClanEntryManager; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| @@ -44,10 +42,10 @@ public class RequestPledgeWaitingApplied implements IClientIncomingPacket | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		final OptionalInt clanId = ClanEntryManager.getInstance().getClanIdForPlayerApplication(player.getObjectId()); | ||||
| 		if (clanId.isPresent()) | ||||
| 		final int clanId = ClanEntryManager.getInstance().getClanIdForPlayerApplication(player.getObjectId()); | ||||
| 		if (clanId > 0) | ||||
| 		{ | ||||
| 			player.sendPacket(new ExPledgeWaitingListApplied(clanId.getAsInt(), player.getObjectId())); | ||||
| 			player.sendPacket(new ExPledgeWaitingListApplied(clanId, player.getObjectId())); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -16,8 +16,6 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.network.clientpackets; | ||||
|  | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.l2jmobius.Config; | ||||
| import org.l2jmobius.commons.network.PacketReader; | ||||
| import org.l2jmobius.gameserver.data.sql.impl.ClanTable; | ||||
| @@ -132,7 +130,19 @@ public class RequestStartPledgeWar implements IClientIncomingPacket | ||||
| 		final ClanWar newClanWar = new ClanWar(clanDeclaringWar, clanDeclaredWar); | ||||
| 		ClanTable.getInstance().storeClanWars(newClanWar); | ||||
| 		 | ||||
| 		clanDeclaringWar.getMembers().stream().filter(Objects::nonNull).filter(ClanMember::isOnline).forEach(p -> p.getPlayerInstance().broadcastUserInfo(UserInfoType.CLAN)); | ||||
| 		clanDeclaredWar.getMembers().stream().filter(Objects::nonNull).filter(ClanMember::isOnline).forEach(p -> p.getPlayerInstance().broadcastUserInfo(UserInfoType.CLAN)); | ||||
| 		for (ClanMember member : clanDeclaringWar.getMembers()) | ||||
| 		{ | ||||
| 			if ((member != null) && member.isOnline()) | ||||
| 			{ | ||||
| 				member.getPlayerInstance().broadcastUserInfo(UserInfoType.CLAN); | ||||
| 			} | ||||
| 		} | ||||
| 		for (ClanMember member : clanDeclaredWar.getMembers()) | ||||
| 		{ | ||||
| 			if ((member != null) && member.isOnline()) | ||||
| 			{ | ||||
| 				member.getPlayerInstance().broadcastUserInfo(UserInfoType.CLAN); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -16,8 +16,6 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.network.clientpackets; | ||||
|  | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.l2jmobius.commons.network.PacketReader; | ||||
| import org.l2jmobius.gameserver.data.sql.impl.ClanTable; | ||||
| import org.l2jmobius.gameserver.enums.ClanWarState; | ||||
| @@ -57,11 +55,14 @@ public class RequestSurrenderPledgeWar implements IClientIncomingPacket | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		if (myClan.getMembers().stream().filter(Objects::nonNull).filter(ClanMember::isOnline).map(ClanMember::getPlayerInstance).anyMatch(p -> !p.isInCombat())) | ||||
| 		for (ClanMember member : myClan.getMembers()) | ||||
| 		{ | ||||
| 			player.sendPacket(SystemMessageId.A_CEASE_FIRE_DURING_A_CLAN_WAR_CAN_NOT_BE_CALLED_WHILE_MEMBERS_OF_YOUR_CLAN_ARE_ENGAGED_IN_BATTLE); | ||||
| 			client.sendPacket(ActionFailed.STATIC_PACKET); | ||||
| 			return; | ||||
| 			if ((member != null) && member.isOnline() && member.getPlayerInstance().isInCombat()) | ||||
| 			{ | ||||
| 				player.sendPacket(SystemMessageId.A_CEASE_FIRE_DURING_A_CLAN_WAR_CAN_NOT_BE_CALLED_WHILE_MEMBERS_OF_YOUR_CLAN_ARE_ENGAGED_IN_BATTLE); | ||||
| 				client.sendPacket(ActionFailed.STATIC_PACKET); | ||||
| 				return; | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		final Clan targetClan = ClanTable.getInstance().getClanByName(_pledgeName); | ||||
|   | ||||
| @@ -17,7 +17,6 @@ | ||||
| package org.l2jmobius.gameserver.network.clientpackets.adenadistribution; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.l2jmobius.commons.network.PacketReader; | ||||
| import org.l2jmobius.gameserver.model.CommandChannel; | ||||
| @@ -144,11 +143,14 @@ public class RequestDivideAdena implements IClientIncomingPacket | ||||
| 	 | ||||
| 	private void cancelDistribution(AdenaDistributionRequest request) | ||||
| 	{ | ||||
| 		request.getPlayers().stream().filter(Objects::nonNull).forEach(p -> | ||||
| 		for (PlayerInstance player : request.getPlayers()) | ||||
| 		{ | ||||
| 			p.sendPacket(SystemMessageId.ADENA_DISTRIBUTION_HAS_BEEN_CANCELLED); | ||||
| 			p.sendPacket(ExDivideAdenaCancel.STATIC_PACKET); | ||||
| 			p.removeRequest(AdenaDistributionRequest.class); | ||||
| 		}); | ||||
| 			if (player != null) | ||||
| 			{ | ||||
| 				player.sendPacket(SystemMessageId.ADENA_DISTRIBUTION_HAS_BEEN_CANCELLED); | ||||
| 				player.sendPacket(ExDivideAdenaCancel.STATIC_PACKET); | ||||
| 				player.removeRequest(AdenaDistributionRequest.class); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @@ -16,8 +16,6 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.network.clientpackets.adenadistribution; | ||||
|  | ||||
| import java.util.Objects; | ||||
|  | ||||
| import org.l2jmobius.commons.network.PacketReader; | ||||
| import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; | ||||
| import org.l2jmobius.gameserver.model.actor.request.AdenaDistributionRequest; | ||||
| @@ -52,12 +50,15 @@ public class RequestDivideAdenaCancel implements IClientIncomingPacket | ||||
| 		if (_cancel) | ||||
| 		{ | ||||
| 			final AdenaDistributionRequest request = player.getRequest(AdenaDistributionRequest.class); | ||||
| 			request.getPlayers().stream().filter(Objects::nonNull).forEach(p -> | ||||
| 			for (PlayerInstance p : request.getPlayers()) | ||||
| 			{ | ||||
| 				p.sendPacket(SystemMessageId.ADENA_DISTRIBUTION_HAS_BEEN_CANCELLED); | ||||
| 				p.sendPacket(ExDivideAdenaCancel.STATIC_PACKET); | ||||
| 				p.removeRequest(AdenaDistributionRequest.class); | ||||
| 			}); | ||||
| 				if (p != null) | ||||
| 				{ | ||||
| 					p.sendPacket(SystemMessageId.ADENA_DISTRIBUTION_HAS_BEEN_CANCELLED); | ||||
| 					p.sendPacket(ExDivideAdenaCancel.STATIC_PACKET); | ||||
| 					p.removeRequest(AdenaDistributionRequest.class); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -50,13 +50,20 @@ public class RequestOneDayRewardReceive implements IClientIncomingPacket | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		final Collection<DailyMissionDataHolder> reward = DailyMissionData.getInstance().getDailyMissionData(_id); | ||||
| 		if ((reward == null) || reward.isEmpty()) | ||||
| 		final Collection<DailyMissionDataHolder> rewards = DailyMissionData.getInstance().getDailyMissionData(_id); | ||||
| 		if ((rewards == null) || rewards.isEmpty()) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
| 		 | ||||
| 		reward.stream().filter(o -> o.isDisplayable(player)).forEach(r -> r.requestReward(player)); | ||||
| 		for (DailyMissionDataHolder holder : rewards) | ||||
| 		{ | ||||
| 			if (holder.isDisplayable(player)) | ||||
| 			{ | ||||
| 				holder.requestReward(player); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		player.sendPacket(new ExConnectedTimeAndGettableReward(player)); | ||||
| 		player.sendPacket(new ExOneDayReceiveRewardList(player, true)); | ||||
| 	} | ||||
|   | ||||
| @@ -16,9 +16,8 @@ | ||||
|  */ | ||||
| package org.l2jmobius.gameserver.network.serverpackets; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Objects; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.commons.network.PacketWriter; | ||||
| import org.l2jmobius.gameserver.model.actor.Creature; | ||||
| @@ -28,19 +27,18 @@ import org.l2jmobius.gameserver.network.OutgoingPackets; | ||||
| public class ExAbnormalStatusUpdateFromTarget implements IClientOutgoingPacket | ||||
| { | ||||
| 	private final Creature _creature; | ||||
| 	private final List<BuffInfo> _effects; | ||||
| 	private final List<BuffInfo> _effects = new ArrayList<>(); | ||||
| 	 | ||||
| 	public ExAbnormalStatusUpdateFromTarget(Creature creature) | ||||
| 	{ | ||||
| 		//@formatter:off | ||||
| 		_creature = creature; | ||||
| 		_effects = creature.getEffectList().getEffects() | ||||
| 					.stream() | ||||
| 					.filter(Objects::nonNull) | ||||
| 					.filter(BuffInfo::isInUse) | ||||
| 					.filter(b -> !b.getSkill().isToggle()) | ||||
| 					.collect(Collectors.toList()); | ||||
| 		//@formatter:on | ||||
| 		for (BuffInfo info : creature.getEffectList().getEffects()) | ||||
| 		{ | ||||
| 			if ((info != null) && info.isInUse() && !info.getSkill().isToggle()) | ||||
| 			{ | ||||
| 				_effects.add(info); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	@Override | ||||
|   | ||||
| @@ -18,7 +18,6 @@ package org.l2jmobius.gameserver.network.serverpackets; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import org.l2jmobius.commons.network.PacketWriter; | ||||
| import org.l2jmobius.gameserver.data.xml.impl.SkillData; | ||||
| @@ -37,7 +36,13 @@ public class ExAlchemySkillList implements IClientOutgoingPacket | ||||
| 	 | ||||
| 	public ExAlchemySkillList(PlayerInstance player) | ||||
| 	{ | ||||
| 		_skills.addAll(player.getAllSkills().stream().filter(s -> SkillTreeData.getInstance().isAlchemySkill(s.getId(), s.getLevel())).collect(Collectors.toList())); | ||||
| 		for (Skill s : player.getAllSkills()) | ||||
| 		{ | ||||
| 			if (SkillTreeData.getInstance().isAlchemySkill(s.getId(), s.getLevel())) | ||||
| 			{ | ||||
| 				_skills.add(s); | ||||
| 			} | ||||
| 		} | ||||
| 		_skills.add(SkillData.getInstance().getSkill(CommonSkill.ALCHEMY_CUBE.getId(), 1)); | ||||
| 	} | ||||
| 	 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment