From 58fe3bdd8f2ba18420e694d2e3a69dd00359d8af Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 24 Jan 2020 15:51:52 +0000 Subject: [PATCH] Dropped addToQuestStateArray method. --- .../model/actor/instance/NpcInstance.java | 2 +- .../model/actor/instance/PlayerInstance.java | 92 ++++--------------- 2 files changed, 21 insertions(+), 73 deletions(-) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java index 948c69e0cd..fb8ccec272 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/NpcInstance.java @@ -1877,7 +1877,7 @@ public class NpcInstance extends Creature // collect awaiting quests and start points final List options = new ArrayList<>(); - final QuestState[] awaits = player.getQuestsForTalk(getTemplate().npcId); + final List awaits = player.getQuestsForTalk(getTemplate().npcId); final Quest[] starts = getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START); // Quests are limited between 1 and 999 because those are the quests that are supported by the client. diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java index 2d853ae35c..7dbef90122 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/instance/PlayerInstance.java @@ -1579,24 +1579,6 @@ public class PlayerInstance extends Playable _quests.remove(quest); } - /** - * Adds the to quest state array. - * @param questStateArray the quest state array - * @param state the state - * @return the quest state[] - */ - private QuestState[] addToQuestStateArray(QuestState[] questStateArray, QuestState state) - { - final int len = questStateArray.length; - final QuestState[] tmp = new QuestState[len + 1]; - for (int i = 0; i < len; i++) - { - tmp[i] = questStateArray[i]; - } - tmp[len] = state; - return tmp; - } - /** * Return a list containing all Quest in progress from the table _quests. * @return the all active quests @@ -1632,15 +1614,14 @@ public class PlayerInstance extends Playable } /** - * Return a table containing all QuestState to modify after a Attackable killing.
- *
+ * Return a table containing all QuestState to modify after a Attackable killing. * @param npc the npc * @return the quests for attacks */ - public QuestState[] getQuestsForAttacks(NpcInstance npc) + public List getQuestsForAttacks(NpcInstance npc) { - // Create a QuestState table that will contain all QuestState to modify - QuestState[] states = null; + // Create a QuestState lisy that will contain all QuestState to modify + List states = new ArrayList<>(); // Go through the QuestState of the PlayerInstance quests for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_ATTACK)) @@ -1649,34 +1630,23 @@ public class PlayerInstance extends Playable if (getQuestState(quest.getName()) != null) { // Copy the current PlayerInstance QuestState in the QuestState table - if (states == null) - { - states = new QuestState[] - { - getQuestState(quest.getName()) - }; - } - else - { - states = addToQuestStateArray(states, getQuestState(quest.getName())); - } + states.add(getQuestState(quest.getName())); } } - // Return a table containing all QuestState to modify + // Return a list containing all QuestState to modify return states; } /** - * Return a table containing all QuestState to modify after a Attackable killing.
- *
+ * Return a table containing all QuestState to modify after a Attackable killing. * @param npc the npc * @return the quests for kills */ - public QuestState[] getQuestsForKills(NpcInstance npc) + public List getQuestsForKills(NpcInstance npc) { - // Create a QuestState table that will contain all QuestState to modify - QuestState[] states = null; + // Create a QuestState lisy that will contain all QuestState to modify + List states = new ArrayList<>(); // Go through the QuestState of the PlayerInstance quests for (Quest quest : npc.getTemplate().getEventQuests(Quest.QuestEventType.ON_KILL)) @@ -1685,34 +1655,23 @@ public class PlayerInstance extends Playable if (getQuestState(quest.getName()) != null) { // Copy the current PlayerInstance QuestState in the QuestState table - if (states == null) - { - states = new QuestState[] - { - getQuestState(quest.getName()) - }; - } - else - { - states = addToQuestStateArray(states, getQuestState(quest.getName())); - } + states.add(getQuestState(quest.getName())); } } - // Return a table containing all QuestState to modify + // Return a list containing all QuestState to modify return states; } /** - * Return a table containing all QuestState from the table _quests in which the PlayerInstance must talk to the NPC.
- *
+ * Return a table containing all QuestState from the table _quests in which the PlayerInstance must talk to the NPC. * @param npcId The Identifier of the NPC * @return the quests for talk */ - public QuestState[] getQuestsForTalk(int npcId) + public List getQuestsForTalk(int npcId) { - // Create a QuestState table that will contain all QuestState to modify - QuestState[] states = null; + // Create a QuestState list that will contain all QuestState to modify + List states = new ArrayList<>(); // Go through the QuestState of the PlayerInstance quests final Quest[] quests = NpcTable.getInstance().getTemplate(npcId).getEventQuests(Quest.QuestEventType.QUEST_TALK); @@ -1723,22 +1682,12 @@ public class PlayerInstance extends Playable // Copy the current PlayerInstance QuestState in the QuestState table if ((quest != null) && (getQuestState(quest.getName()) != null)) { - if (states == null) - { - states = new QuestState[] - { - getQuestState(quest.getName()) - }; - } - else - { - states = addToQuestStateArray(states, getQuestState(quest.getName())); - } + states.add(getQuestState(quest.getName())); } } } - // Return a table containing all QuestState to modify + // Return a list containing all QuestState to modify return states; } @@ -1787,9 +1736,8 @@ public class PlayerInstance extends Playable if ((object instanceof NpcInstance) && isInsideRadius(object, NpcInstance.INTERACTION_DISTANCE, false, false)) { final NpcInstance npc = (NpcInstance) object; - final QuestState[] states = getQuestsForTalk(npc.getNpcId()); - - if (states != null) + final List states = getQuestsForTalk(npc.getNpcId()); + if (!states.isEmpty()) { for (QuestState state : states) {