TaskRecom.java 2.3 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 net.sf.l2j.gameserver.taskmanager.tasks;
  16. import java.util.Collection;
  17. import java.util.logging.Logger;
  18. import net.sf.l2j.gameserver.model.L2World;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.network.serverpackets.UserInfo;
  21. import net.sf.l2j.gameserver.taskmanager.Task;
  22. import net.sf.l2j.gameserver.taskmanager.TaskManager;
  23. import net.sf.l2j.gameserver.taskmanager.TaskTypes;
  24. import net.sf.l2j.gameserver.taskmanager.TaskManager.ExecutedTask;
  25. /**
  26. * @author Layane
  27. *
  28. */
  29. public class TaskRecom extends Task
  30. {
  31. private static final Logger _log = Logger.getLogger(TaskRecom.class.getName());
  32. private static final String NAME = "sp_recommendations";
  33. /**
  34. *
  35. * @see net.sf.l2j.gameserver.taskmanager.Task#getName()
  36. */
  37. @Override
  38. public String getName()
  39. {
  40. return NAME;
  41. }
  42. /**
  43. *
  44. * @see net.sf.l2j.gameserver.taskmanager.Task#onTimeElapsed(net.sf.l2j.gameserver.taskmanager.TaskManager.ExecutedTask)
  45. */
  46. @Override
  47. public void onTimeElapsed(ExecutedTask task)
  48. {
  49. Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
  50. // synchronized (L2World.getInstance().getAllPlayers())
  51. {
  52. for (L2PcInstance player : pls)
  53. {
  54. player.restartRecom();
  55. player.sendPacket(new UserInfo(player));
  56. }
  57. }
  58. _log.config("Recommendation Global Task: launched.");
  59. }
  60. /**
  61. *
  62. * @see net.sf.l2j.gameserver.taskmanager.Task#initializate()
  63. */
  64. @Override
  65. public void initializate()
  66. {
  67. super.initializate();
  68. TaskManager.addUniqueTask(NAME, TaskTypes.TYPE_GLOBAL_TASK, "1", "13:00:00", "");
  69. }
  70. }