*
* @param player : Player who is entering the world
*/
public static void playerEnter(L2Player player)
{
ThreadConnection con = null;
FiltredPreparedStatement statement = null;
FiltredPreparedStatement invalidQuestData = null;
ResultSet rset = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? and name=?");
statement = con.prepareStatement("SELECT name,value FROM character_quests WHERE char_id=? AND var=?");
statement.setInt(1, player.getObjectId());
statement.setString(2, "<state>");
rset = statement.executeQuery();
while(rset.next())
{
String questId = rset.getString("name");
String state = rset.getString("value");
if(state.equalsIgnoreCase("Start")) // невзятый квест
{
invalidQuestData.setInt(1, player.getObjectId());
invalidQuestData.setString(2, questId);
invalidQuestData.executeUpdate();
continue;
}
// Search quest associated with the ID
Quest q = QuestManager.getQuest(questId);
if(q == null)
{
if(!Config.DONTLOADQUEST)
{
_log.warning("Unknown quest " + questId + " for player " + player.getName());
}
continue;
}
// Create a new QuestState for the player that will be added to the player's list of quests
new QuestState(q, player, getStateId(state));
}
invalidQuestData.close();
DatabaseUtils.closeDatabaseSR(statement, rset);
// Get list of quests owned by the player from the DB in order to add variables used in the quest.
statement = con.prepareStatement("SELECT name,var,value FROM character_quests WHERE char_id=?");
statement.setInt(1, player.getObjectId());
rset = statement.executeQuery();
while(rset.next())
{
String questId = rset.getString("name");