TaskDailySkillReuseClean.java 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.taskmanager.tasks;
  20. import java.sql.Connection;
  21. import java.sql.PreparedStatement;
  22. import com.l2jserver.commons.database.pool.impl.ConnectionFactory;
  23. import com.l2jserver.gameserver.taskmanager.Task;
  24. import com.l2jserver.gameserver.taskmanager.TaskManager;
  25. import com.l2jserver.gameserver.taskmanager.TaskManager.ExecutedTask;
  26. import com.l2jserver.gameserver.taskmanager.TaskTypes;
  27. public class TaskDailySkillReuseClean extends Task
  28. {
  29. private static final String NAME = "daily_skill_clean";
  30. private static final int[] _daily_skills =
  31. {
  32. 2510,
  33. 22180
  34. };
  35. @Override
  36. public String getName()
  37. {
  38. return NAME;
  39. }
  40. @Override
  41. public void onTimeElapsed(ExecutedTask task)
  42. {
  43. try (Connection con = ConnectionFactory.getInstance().getConnection())
  44. {
  45. for (int skill_id : _daily_skills)
  46. {
  47. try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_skills_save WHERE skill_id=?;"))
  48. {
  49. ps.setInt(1, skill_id);
  50. ps.execute();
  51. }
  52. }
  53. }
  54. catch (Exception e)
  55. {
  56. _log.severe(getClass().getSimpleName() + ": Could not reset daily skill reuse: " + e);
  57. }
  58. _log.info("Daily skill reuse cleaned.");
  59. }
  60. @Override
  61. public void initializate()
  62. {
  63. super.initializate();
  64. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "06:30:00", "");
  65. }
  66. }