TaskDailySkillReuseClean.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_clean";
  29. private static final int[] _daily_skills =
  30. {
  31. 2510, 22180
  32. };
  33. @Override
  34. public String getName()
  35. {
  36. return NAME;
  37. }
  38. @Override
  39. public void onTimeElapsed(ExecutedTask task)
  40. {
  41. Connection con = null;
  42. try
  43. {
  44. con = L2DatabaseFactory.getInstance().getConnection();
  45. for (int skill_id : _daily_skills)
  46. {
  47. PreparedStatement statement = con.prepareStatement("DELETE FROM character_skills_save WHERE skill_id=?;");
  48. statement.setInt(1, skill_id);
  49. statement.execute();
  50. statement.close();
  51. }
  52. }
  53. catch (Exception e)
  54. {
  55. _log.log(Level.SEVERE, "Could not reset daily skill reuse: " + e);
  56. }
  57. finally
  58. {
  59. L2DatabaseFactory.close(con);
  60. }
  61. _log.config("Daily skill reuse cleaned.");
  62. }
  63. @Override
  64. public void initializate()
  65. {
  66. super.initializate();
  67. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
  68. }
  69. }