FourSepulchersChangeEntryTimeTask.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.instancemanager.tasks;
  20. import java.util.Calendar;
  21. import java.util.concurrent.ScheduledFuture;
  22. import com.l2jserver.Config;
  23. import com.l2jserver.gameserver.ThreadPoolManager;
  24. import com.l2jserver.gameserver.instancemanager.FourSepulchersManager;
  25. /**
  26. * Four Sepulchers change entry time task.
  27. * @author xban1x
  28. */
  29. public final class FourSepulchersChangeEntryTimeTask implements Runnable
  30. {
  31. @Override
  32. public void run()
  33. {
  34. final FourSepulchersManager manager = FourSepulchersManager.getInstance();
  35. manager.setIsEntryTime(true);
  36. manager.setIsWarmUpTime(false);
  37. manager.setIsAttackTime(false);
  38. manager.setIsCoolDownTime(false);
  39. long interval = 0;
  40. // if this is first launch - search time whFourSepulchersManager_inEntryTime = true;naFourSepulchersManager_inEntryTime = true;maen entry time will be
  41. // ended:
  42. // counting difference between time when entry time ends and current
  43. // time
  44. // and then launching change time task
  45. if (manager.isFirstTimeRun())
  46. {
  47. interval = manager.getEntrytTimeEnd() - Calendar.getInstance().getTimeInMillis();
  48. }
  49. else
  50. {
  51. interval = Config.FS_TIME_ENTRY * 60000L; // else use stupid
  52. // method
  53. }
  54. // launching saying process...
  55. ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersManagerSayTask(), 0);
  56. manager.setChangeWarmUpTimeTask(ThreadPoolManager.getInstance().scheduleEffect(new FourSepulchersChangeWarmUpTimeTask(), interval));
  57. final ScheduledFuture<?> changeEntryTimeTask = manager.getChangeEntryTimeTask();
  58. if (changeEntryTimeTask != null)
  59. {
  60. changeEntryTimeTask.cancel(true);
  61. manager.setChangeEntryTimeTask(null);
  62. }
  63. }
  64. }