FourSepulchersChangeWarmUpTimeTask.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 warm up time task.
  27. * @author xban1x
  28. */
  29. public final class FourSepulchersChangeWarmUpTimeTask 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. // searching time when warmup time will be ended:
  41. // counting difference between time when warmup time ends and
  42. // current time
  43. // and then launching change time task
  44. if (manager.isFirstTimeRun())
  45. {
  46. interval = manager.getWarmUpTimeEnd() - Calendar.getInstance().getTimeInMillis();
  47. }
  48. else
  49. {
  50. interval = Config.FS_TIME_WARMUP * 60000L;
  51. }
  52. manager.setChangeAttackTimeTask(ThreadPoolManager.getInstance().scheduleGeneral(new FourSepulchersChangeAttackTimeTask(), interval));
  53. final ScheduledFuture<?> changeWarmUpTimeTask = manager.getChangeWarmUpTimeTask();
  54. if (changeWarmUpTimeTask != null)
  55. {
  56. changeWarmUpTimeTask.cancel(true);
  57. manager.setChangeWarmUpTimeTask(null);
  58. }
  59. }
  60. }