Removed stream usage from Player.
This commit is contained in:
@@ -27,11 +27,11 @@ import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentSkipListMap;
|
||||
@@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
@@ -1554,24 +1553,33 @@ public class Player extends Playable
|
||||
/**
|
||||
* @return List of {@link QuestState}s of the current player.
|
||||
*/
|
||||
public List<QuestState> getAllQuestStates()
|
||||
public Collection<QuestState> getAllQuestStates()
|
||||
{
|
||||
return new ArrayList<>(_quests.values());
|
||||
return _quests.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a table containing all Quest in progress from the table _quests.
|
||||
*/
|
||||
public List<Quest> getAllActiveQuests()
|
||||
public Collection<Quest> getAllActiveQuests()
|
||||
{
|
||||
//@formatter:off
|
||||
return _quests.values().stream()
|
||||
.filter(QuestState::isStarted)
|
||||
.map(QuestState::getQuest)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(q -> q.getId() > 1)
|
||||
.collect(Collectors.toList());
|
||||
//@formatter:on
|
||||
final List<Quest> activeQuests = new LinkedList<>();
|
||||
for (QuestState questState : _quests.values())
|
||||
{
|
||||
if (!questState.isStarted())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Quest quest = questState.getQuest();
|
||||
if ((quest == null) || (quest.getId() <= 1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
activeQuests.add(quest);
|
||||
}
|
||||
return activeQuests;
|
||||
}
|
||||
|
||||
public void processQuestEvent(String questName, String event)
|
||||
@@ -5570,7 +5578,12 @@ public class Player extends Playable
|
||||
|
||||
public Summon getFirstServitor()
|
||||
{
|
||||
return getServitors().values().stream().findFirst().orElse(null);
|
||||
if (getServitors().isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return getServitors().values().iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -12246,7 +12259,17 @@ public class Player 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());
|
||||
final List<Skill> filteredSkills = new LinkedList<>();
|
||||
for (Skill skill : currentSkills)
|
||||
{
|
||||
if (!skill.allowOnTransform())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
filteredSkills.add(skill);
|
||||
}
|
||||
currentSkills = filteredSkills;
|
||||
|
||||
// Revelation skills.
|
||||
if (isDualClassActive())
|
||||
@@ -12275,18 +12298,22 @@ public class Player extends Playable
|
||||
addSkill(SkillData.getInstance().getSkill(revelationSkill, 1), false);
|
||||
}
|
||||
}
|
||||
|
||||
// Include transformation skills.
|
||||
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
|
||||
final List<Skill> finalSkills = new LinkedList<>();
|
||||
for (Skill skill : currentSkills)
|
||||
{
|
||||
if ((skill == null) || skill.isBlockActionUseSkill() || SkillTreeData.getInstance().isAlchemySkill(skill.getId(), skill.getLevel()) || !skill.isDisplayInList())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
finalSkills.add(skill);
|
||||
}
|
||||
return finalSkills;
|
||||
}
|
||||
|
||||
protected void startFeed(int npcId)
|
||||
@@ -14100,7 +14127,12 @@ public class Player extends Playable
|
||||
*/
|
||||
public int getSummonPoints()
|
||||
{
|
||||
return getServitors().values().stream().mapToInt(Summon::getSummonPoints).sum();
|
||||
int totalPoints = 0;
|
||||
for (Summon summon : getServitors().values())
|
||||
{
|
||||
totalPoints += summon.getSummonPoints();
|
||||
}
|
||||
return totalPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14114,7 +14146,14 @@ public class Player extends Playable
|
||||
|
||||
public boolean canRequest(AbstractRequest request)
|
||||
{
|
||||
return _requests.values().stream().allMatch(request::canWorkWith);
|
||||
for (AbstractRequest r : _requests.values())
|
||||
{
|
||||
if (!request.canWorkWith(r))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14146,7 +14185,14 @@ public class Player extends Playable
|
||||
|
||||
public boolean hasItemRequest()
|
||||
{
|
||||
return _requests.values().stream().anyMatch(AbstractRequest::isItemRequest);
|
||||
for (AbstractRequest request : _requests.values())
|
||||
{
|
||||
if (request.isItemRequest())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14173,7 +14219,14 @@ public class Player extends Playable
|
||||
*/
|
||||
public boolean isProcessingItem(int objectId)
|
||||
{
|
||||
return _requests.values().stream().anyMatch(req -> req.isUsing(objectId));
|
||||
for (AbstractRequest request : _requests.values())
|
||||
{
|
||||
if (request.isUsing(objectId))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -15081,10 +15134,7 @@ public class Player extends Playable
|
||||
|
||||
private void restoreCollections()
|
||||
{
|
||||
if (_collections != null)
|
||||
{
|
||||
_collections.clear();
|
||||
}
|
||||
_collections.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_COLLECTION))
|
||||
@@ -15110,10 +15160,24 @@ public class Player extends Playable
|
||||
|
||||
private void restoreCollectionBonuses()
|
||||
{
|
||||
getCollections().stream().map(PlayerCollectionData::getCollectionId).collect(Collectors.toSet()).forEach(collectionId ->
|
||||
final Set<Integer> collectionIds = new HashSet<>();
|
||||
for (PlayerCollectionData collection : _collections)
|
||||
{
|
||||
collectionIds.add(collection.getCollectionId());
|
||||
}
|
||||
|
||||
for (int collectionId : collectionIds)
|
||||
{
|
||||
final CollectionDataHolder collection = CollectionData.getInstance().getCollection(collectionId);
|
||||
if (getCollections().stream().filter(it -> it.getCollectionId() == collectionId).count() >= collection.getCompleteCount())
|
||||
int count = 0;
|
||||
for (PlayerCollectionData data : _collections)
|
||||
{
|
||||
if (data.getCollectionId() == collectionId)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count >= collection.getCompleteCount())
|
||||
{
|
||||
final Options options = OptionData.getInstance().getOptions(collection.getOptionId());
|
||||
if (options != null)
|
||||
@@ -15121,15 +15185,12 @@ public class Player extends Playable
|
||||
options.apply(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreCollectionFavorites()
|
||||
{
|
||||
if (_collectionFavorites != null)
|
||||
{
|
||||
_collectionFavorites.clear();
|
||||
}
|
||||
_collectionFavorites.clear();
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement statement = con.prepareStatement(RESTORE_COLLECTION_FAVORITE))
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package org.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.quest.Quest;
|
||||
@@ -29,7 +29,7 @@ import org.l2jmobius.gameserver.network.ServerPackets;
|
||||
public class GmViewQuestInfo extends ServerPacket
|
||||
{
|
||||
private final Player _player;
|
||||
private final List<Quest> _questList;
|
||||
private final Collection<Quest> _questList;
|
||||
|
||||
public GmViewQuestInfo(Player player)
|
||||
{
|
||||
|
Reference in New Issue
Block a user