Browse Source

BETA: Adding Quest#getQuestState(player) method.
* Patch by: jurchiks
* Reviewed by: UnAfraid

xban1x 11 years ago
parent
commit
523f744c6b

+ 20 - 1
L2J_Server_BETA/java/com/l2jserver/gameserver/model/quest/Quest.java

@@ -215,7 +215,26 @@ public class Quest extends ManagedScript implements IIdentifiable
 	 */
 	 */
 	public QuestState newQuestState(L2PcInstance player)
 	public QuestState newQuestState(L2PcInstance player)
 	{
 	{
-		return new QuestState(this, player, getInitialState());
+		return new QuestState(this, player, _initialState);
+	}
+	
+	/**
+	 * Get the specified player's {@link QuestState} object for this quest.<br>
+	 * If the player does not have it and initIfNode is {@code true},<br>
+	 * create a new QuestState object and return it, otherwise return {@code null}.
+	 * @param player the player whose QuestState to get
+	 * @param initIfNone if true and the player does not have a QuestState for this quest,<br>
+	 *            create a new QuestState
+	 * @return the QuestState object for this quest or null if it doesn't exist
+	 */
+	public QuestState getQuestState(L2PcInstance player, boolean initIfNone)
+	{
+		final QuestState qs = player.getQuestState(_name);
+		if ((qs != null) || !initIfNone)
+		{
+			return qs;
+		}
+		return newQuestState(player);
 	}
 	}
 	
 	
 	/**
 	/**