TaskDailyQuestClean.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 java.util.logging.Level;
  19. import java.util.logging.Logger;
  20. import com.l2jserver.L2DatabaseFactory;
  21. import com.l2jserver.gameserver.taskmanager.Task;
  22. import com.l2jserver.gameserver.taskmanager.TaskManager;
  23. import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
  24. import com.l2jserver.gameserver.taskmanager.TaskTypes;
  25. /**
  26. ** @author Gnacik
  27. **
  28. */
  29. public class TaskDailyQuestClean extends Task
  30. {
  31. private static final Logger _log = Logger.getLogger(TaskDailyQuestClean.class.getName());
  32. private static final String NAME = "daily_quest_clean";
  33. private static final String[] _daily_names = {
  34. "463_IMustBeaGenius",
  35. "464_Oath",
  36. "458_PerfectForm",
  37. "461_RumbleInTheBase"
  38. };
  39. /**
  40. *
  41. * @see com.l2jserver.gameserver.taskmanager.Task#getName()
  42. */
  43. @Override
  44. public String getName()
  45. {
  46. return NAME;
  47. }
  48. /**
  49. *
  50. * @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
  51. */
  52. @Override
  53. public void onTimeElapsed(ExecutedTask task)
  54. {
  55. Connection con = null;
  56. try
  57. {
  58. con = L2DatabaseFactory.getInstance().getConnection();
  59. for(String name : _daily_names)
  60. {
  61. PreparedStatement statement = con.prepareStatement("DELETE FROM character_quests WHERE name=? AND var='<state>' AND value='Completed';");
  62. statement.setString(1, name);
  63. statement.execute();
  64. statement.close();
  65. }
  66. }
  67. catch (Exception e)
  68. {
  69. _log.log(Level.SEVERE, "Could not reset daily quests: " + e);
  70. }
  71. finally
  72. {
  73. L2DatabaseFactory.close(con);
  74. }
  75. _log.config("Daily quests cleared");
  76. }
  77. /**
  78. *
  79. * @see com.l2jserver.gameserver.taskmanager.Task#initializate()
  80. */
  81. @Override
  82. public void initializate()
  83. {
  84. super.initializate();
  85. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
  86. }
  87. }