2
0

TaskDailyQuestClean.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.taskmanager.tasks;
  16. import java.sql.Connection;
  17. import java.sql.PreparedStatement;
  18. import com.l2jserver.L2DatabaseFactory;
  19. import com.l2jserver.gameserver.taskmanager.Task;
  20. import com.l2jserver.gameserver.taskmanager.TaskManager;
  21. import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
  22. import com.l2jserver.gameserver.taskmanager.TaskTypes;
  23. /**
  24. * @author Gnacik
  25. */
  26. public class TaskDailyQuestClean extends Task
  27. {
  28. private static final String NAME = "daily_quest_clean";
  29. private static final String[] _daily_names =
  30. {
  31. "463_IMustBeaGenius",
  32. "464_Oath",
  33. "458_PerfectForm",
  34. "461_RumbleInTheBase",
  35. "551_OlympiadStarter",
  36. "552_OlympiadVeteran",
  37. "553_OlympiadUndefeated"
  38. };
  39. @Override
  40. public String getName()
  41. {
  42. return NAME;
  43. }
  44. @Override
  45. public void onTimeElapsed(ExecutedTask task)
  46. {
  47. Connection con = null;
  48. try
  49. {
  50. con = L2DatabaseFactory.getInstance().getConnection();
  51. for (String name : _daily_names)
  52. {
  53. PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE name=? AND var='<state>' AND value='Completed';");
  54. statement.setString(1, name);
  55. statement.execute();
  56. statement.close();
  57. }
  58. }
  59. catch (Exception e)
  60. {
  61. _log.severe(getClass().getSimpleName() + ": Could not reset daily quests: " + e);
  62. }
  63. finally
  64. {
  65. L2DatabaseFactory.close(con);
  66. }
  67. _log.info("Daily quests cleared");
  68. }
  69. @Override
  70. public void initializate()
  71. {
  72. super.initializate();
  73. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
  74. }
  75. }