TaskDailySkillReuseClean.java 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. public class TaskDailySkillReuseClean extends Task
  26. {
  27. private static final Logger _log = Logger.getLogger(TaskDailySkillReuseClean.class.getName());
  28. private static final String NAME = "daily_skill_clearn";
  29. private static final int[] _daily_skills = {
  30. 2510
  31. };
  32. /**
  33. *
  34. * @see com.l2jserver.gameserver.taskmanager.Task#getName()
  35. */
  36. @Override
  37. public String getName()
  38. {
  39. return NAME;
  40. }
  41. /**
  42. *
  43. * @see com.l2jserver.gameserver.taskmanager.Task#onTimeElapsed(com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask)
  44. */
  45. @Override
  46. public void onTimeElapsed(ExecutedTask task)
  47. {
  48. Connection con = null;
  49. try
  50. {
  51. con = L2DatabaseFactory.getInstance().getConnection();
  52. for(int skill_id : _daily_skills)
  53. {
  54. PreparedStatement statement = con.prepareStatement("DELETE FROM character_skills_save WHERE skill_id=?;");
  55. statement.setInt(1, skill_id);
  56. statement.execute();
  57. statement.close();
  58. }
  59. }
  60. catch (Exception e)
  61. {
  62. _log.log(Level.SEVERE, "Could not reset daily skill reuse: " + e);
  63. }
  64. finally
  65. {
  66. L2DatabaseFactory.close(con);
  67. }
  68. _log.config("Daily skill reuse cleared");
  69. }
  70. /**
  71. *
  72. * @see com.l2jserver.gameserver.taskmanager.Task#initializate()
  73. */
  74. @Override
  75. public void initializate()
  76. {
  77. super.initializate();
  78. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
  79. }
  80. }