TaskDailySkillReuseClean.java 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. PreparedStatement statement = con.prepareStatement("DELETE FROM character_skills_save WHERE skill_id=?;");
  46. statement.setInt(1, skill_id);
  47. statement.execute();
  48. statement.close();
  49. }
  50. }
  51. catch (Exception e)
  52. {
  53. _log.severe(getClass().getSimpleName() + ": Could not reset daily skill reuse: " + e);
  54. }
  55. finally
  56. {
  57. L2DatabaseFactory.close(con);
  58. }
  59. _log.info("Daily skill reuse cleaned.");
  60. }
  61. @Override
  62. public void initializate()
  63. {
  64. super.initializate();
  65. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
  66. }
  67. }