TaskDailySkillReuseClean.java 2.1 KB

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